50分求解?在VB6.0中查询Access数据库多字段并加条件查询
在VB6.0中查询Access数据库多字段并加条件查询,代码如下:PrivateSubCommand1_Click()strfilename="E:\XXZL\tEST....
在VB6.0中查询Access数据库多字段并加条件查询,代码如下:
Private Sub Command1_Click()
strfilename = "E:\XXZL\tEST.mdb"
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.CursorLocation = adUseClient
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & strfilename & ";Persist Security Info=False"
cn.Open ConnectionString
StrSQL = "select DD,BB,CC,AA from RES where AA= '" & Text1.Text & "'"
rs.Open StrSQL, cn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
------------------------------
Access数据库如图所示,有字段AA,BB,CC,DD
运行上面代码比如我要查询值ab1,表里的所有ab1查询出来,但是我还想加一个条件就是,把表里的数值为ab1,同时在字段DD中的值为1的,(意思是,把表里值DD字段为1的同时又要是AA字段值为ab1同时查询出来),友友们帮帮忙,送上50分. 展开
Private Sub Command1_Click()
strfilename = "E:\XXZL\tEST.mdb"
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.CursorLocation = adUseClient
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & strfilename & ";Persist Security Info=False"
cn.Open ConnectionString
StrSQL = "select DD,BB,CC,AA from RES where AA= '" & Text1.Text & "'"
rs.Open StrSQL, cn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
------------------------------
Access数据库如图所示,有字段AA,BB,CC,DD
运行上面代码比如我要查询值ab1,表里的所有ab1查询出来,但是我还想加一个条件就是,把表里的数值为ab1,同时在字段DD中的值为1的,(意思是,把表里值DD字段为1的同时又要是AA字段值为ab1同时查询出来),友友们帮帮忙,送上50分. 展开
4个回答
展开全部
Private Sub Command1_Click()
strfilename = "E:\XXZL\tEST.mdb"
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.CursorLocation = adUseClient
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & strfilename & ";Persist Security Info=False"
cn.Open ConnectionString
StrSQL = "select DD,BB,CC,AA from RES where AA= '" & Text1.Text & "' and DD='1'"
rs.Open StrSQL, cn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
strfilename = "E:\XXZL\tEST.mdb"
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.CursorLocation = adUseClient
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & strfilename & ";Persist Security Info=False"
cn.Open ConnectionString
StrSQL = "select DD,BB,CC,AA from RES where AA= '" & Text1.Text & "' and DD='1'"
rs.Open StrSQL, cn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
展开全部
Private Sub Command1_Click()
dim aa as integer
strfilename = "E:\XXZL\tEST.mdb"
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.CursorLocation = adUseClient
aa=1
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & strfilename & ";Persist Security Info=False"
cn.Open ConnectionString
StrSQL = "select DD,BB,CC,AA from RES where AA= '" & Text1.Text & "' and DD=“ & aa
rs.Open StrSQL, cn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
dim aa as integer
strfilename = "E:\XXZL\tEST.mdb"
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.CursorLocation = adUseClient
aa=1
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & strfilename & ";Persist Security Info=False"
cn.Open ConnectionString
StrSQL = "select DD,BB,CC,AA from RES where AA= '" & Text1.Text & "' and DD=“ & aa
rs.Open StrSQL, cn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
StrSQL = "select DD,BB,CC,AA from RES where AA= '" & Text1.Text & " and dd= '" & Text2.Text & "'"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如图所示的问题,要实现多条件查询,即在第一个组合框中输入条件1单击查询"Provider=Microsoft.Jet.OLEDB.4.0;data source=你的数据库文件.mdb;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询