请教vb显示access
本帖最后由 bcrun 于 2013-06-18 16:08:23 编辑
Private Sub Form_Load()
Form2.Text1.Text = Form1.Text1.Text
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SqlStr As String
Dim SqlStr1 As String
Dim SqlStr2 As String
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False"
SqlStr = "select * from member where username='" & Text1.Text & "' and hailfellow='true'"
SqlStr1 = "select * from member where username='" & Text1.Text & "' and blacklist='true'"
SqlStr2 = "select * from member where username='" & Text1.Text & "' and stranger='true'"
rs.CursorLocation = adUseClient
rs.Open SqlStr, cn, adOpenDynamic, adLockOptimistic, adCmdText '打开记录集
Do While rs.EOF = False
Combo1.AddItem rs.Fields("mymember").Value
rs.MoveNext
Loop
End Sub
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data.mdb;Mode=ReadWrite
[解决办法]
Share Deny None;Persist Security Info=False"
SqlStr = "select * from member where username='" & Text1.Text & "' and hailfellow='true'"
rs.CursorLocation = adUseClient
rs.Open SqlStr, cn, adOpenDynamic, adLockOptimistic, adCmdText '打开记录集
Combo1.Clear
Do While rs.EOF = False
Combo1.AddItem rs.Fields("mymember").Value
rs.MoveNext
Loop
rs.Close
SqlStr1 = "select * from member where username='" & Text1.Text & "' and blacklist='true'"
rs.Open SqlStr1, cn, adOpenDynamic, adLockOptimistic, adCmdText '打开记录集
Combo1.Clear
Do While rs.EOF = False
Combo2.AddItem rs.Fields("mymember").Value
rs.MoveNext
Loop
rs.Close
SqlStr2 = "select * from member where username='" & Text1.Text & "' and stranger='true'"
rs.Open SqlStr2, cn, adOpenDynamic, adLockOptimistic, adCmdText '打开记录集
Combo1.Clear
Do While rs.EOF = False
Combo3.AddItem rs.Fields("mymember").Value
rs.MoveNext
Loop