菜鸟新手求助vb查询问题
小弟最近做毕业设计,在做查询窗体时
老是出下面问题,请各位高手大大救救,在线等待
调试时出现:在对应所需名称或序数的 集合中未找到项目!
请教这是什么问题,怎么改,我用的是参数查询,源代码在下
Dim objrs As Recordset, objsource As Recordset
objcmd("药品名称") = " % " & Text1 & " % "
objcmd("销售客户") = " % " & Text2 & " % " '这里出现问题了,提示在对应所需名称或序数的 集合中未找到项目!
Set objrs = objcmd.Execute()
Set objsource = New Recordset
For i = 0 To objrs.Fields.Count - 1
objsource.Fields.Append objrs.Fields(i).Name, adVarChar, objrs.Fields(i).DefinedSize
Next
objsource.Open
While Not objrs.EOF
objsource.AddNew
objsource!药品名称 = objrs!药品名称
objsource!编号 = objrs!编号
objsource!销售客户 = objrs!销售客户
objsource!售价 = objrs!售价
objsource!销售数量 = objrs!销售数量
objsource!销售日期 = objrs!销售日期
objsource!总价 = objrs!总价
objsource!实际付款 = objrs!实际付款
objsource!欠款 = objrs!欠款
objsource!药品编号 = objrs!药品编号
objrs.MoveNext
Wend
If objsource.RecordCount > 0 Then objsource.MoveFirst
Set DataGrid1.DataSource = objsource
Label4 = "共获得" & objsource.RecordCount & "条查询结果"
Private Sub Form_Load()
Dim objcn As New Connection, objcmd As New Command
Set objcn = New Connection
objcn = "Provider=microsoft.jet.oledb.4.0;Persist Security Info=False;Data Source=g:\db1.mdb"
objcn.Open
With objcmd
.CommandText = "select*from 销售信息表 where 药品名称 like?" & "and 销售客户 like?"
.CommandType = adCmdText
End With
Dim parm As New Parameter
Set parm = objcmd.CreateParameter("药品名称", adChar, adParamInput, 10)
objcmd.Parameters.Append parm
Set parm = objcmd.CreateParameter("销售客户", adChar, adParamInput, 10)
Label4 = ""
End Sub