帮忙看一下,我想作一个查询复合多条条件的记录,我这样写总是查不出来,怎么改能改成查出复合多个条件的记录
Dim mysql As String
mysql = "select * from s where sno is not null"
If Check1.Value Then
mysql = mysql & " and sno='" & Text2.Text & "' "
If Check2.Value Then
mysql = mysql & " and sn='" & Text3.Text & "' "
If Check3.Value Then
mysql = mysql & " and sex='" & Text4.Text & "' "
If Check4.Value Then
mysql = mysql & " and age=" & Text5.Text & " "
If Check5.Value Then
mysql = mysql & " and dept='" & Text6.Text & "' "
If Check6.Value Then
mysql = mysql & " and nn='" & Text7.Text & "' "
End If
End If
End If
End If
End If
End If
Set i = New ADODB.Connection
Set j = New ADODB.Recordset
i.ConnectionString = "provider=sqloledb.1;data source=(local);user id=sa;pwd=247162545;initial catalog=sdb"
i.Open
j.Open mysql, i, adOpenDynamic, adLockOptimistic
Set MSHFlexGrid1.DataSource = j
Text8.Text = mysql