这个程序是我写的参数查询,但是查一条记录就是模糊查询,怎么修改能改成精确查询
还有怎么样改能改成查询符合多个查询条件的复合查询
Dim i As Connection
Dim k As New Command
Private Sub Command1_Click()
Dim objrs As Recordset
Dim objsource As Recordset
k("yhm") = "%" & Text1 & "%"
k("mm") = "%" & Text2 & "%"
Set objrs = k.Execute()
Set objsource = New Recordset
For a = 0 To objrs.Fields.Count - 1
objsource.Fields.Append objrs.Fields(a).Name, adChar, objrs.Fields(a).DefinedSize
Next
objsource.Open
While Not objrs.EOF
objsource.AddNew
objsource!yhm = objrs!yhm
objsource!mm = objrs!mm
objrs.MoveNext
Wend
If objsource.RecordCount > 0 Then objsource.MoveFirst
Set DataGrid1.DataSource = objsource
End Sub
Private Sub Form_Load()
Set i = New ADODB.Connection
i.ConnectionString = "provider=sqloledb.1;data source=(local);user id=sa;pwd=247162545;initial catalog=sdb"
i.Open
k.ActiveConnection = i
k.CommandText = "select * from yh where yhm like ? and mm like ?"
k.CommandType = adCmdText
Dim parm As New Parameter
Set parm = k.CreateParameter("yhm", adChar, adParamInput, 10)
k.Parameters.Append parm
Set parm = k.CreateParameter("mm", adChar, adParamInput, 10)
k.Parameters.Append parm
End Sub