回复 13楼 lowxiong
大师果然奏效,不过还是有点瑕疵,就是默认了性别是男,我改了一下,正好符合我的要求,已经没有问题
Private Sub Command1_Click()
Dim cmd As New Command
Set rs5 = New ADODB.Recordset
cmd.ActiveConnection = conn
conn.CursorLocation = adUseClient
= adCmdStoredProc
= "query_friends"
cmd.Parameters("@qcname") = "%" & Trim(Combo1.Text) & "%"
cmd.Parameters("@qcsex") = "%"
If Trim(Combo2.Text) <> "" Then cmd.Parameters("@qcsex") = Trim(Combo2.Text)
cmd.Parameters("@qcrela") = "%" & Trim(Combo3.Text) & "%"
cmd.Parameters("@qcposs") = "%" & Trim(Combo4.Text) & "%"
Set rs5 = cmd.Execute
Set DataGrid1.DataSource = rs5
Set cmd = Nothing
Set rs5 = Nothing
End Sub
我在form_load里加了combo的第一个值都为空,这样如果不选任何一个combo,查询的就是全部结果
感谢您耐心的解答,严重感谢了!!!