为什么在VB的ACCESS模糊查询时出错?
在这句“Rs.Open "SELECT * from 费用清单 Where " & Combo1.Text & " Like '%" & Text1.Text & "%'", Cn, 3, 2”时,出现“至少一个参数没有被指定值”。代码如下:
查询.rar
(6.3 KB)
Option Explicit
Dim Cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Private Sub Command6_Click()
If Rs.State <> adStateClosed Then Rs.Close
If Cn.State <> adStateClosed Then Cn.Close
Cn.ConnectionString = "provider=Microsoft.jet.OLEDB.4.0;" & "Persist security info= False; Data source=" & App.Path & "\商铺装修收费系统.mdb" '(资料库路径和名称)
Rs.CursorLocation = adUseClient
Cn.Open
Rs.Open "SELECT * from 费用清单 Where " & Combo1.Text & " Like '%" & Text1.Text & "%'", Cn, 3, 2
Set DataGrid1.DataSource = Rs
DataGrid1.Refresh
End Sub
Private Sub Form_Load()
Text1.Text = "S"
Combo1.Text = "商户品牌/单位名称"
Set Cn = CreateObject("ADODB.Connection")
Set Rs = CreateObject("ADODB.Recordset")
Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\商铺装修收费系统.MDB;Persist Security Info=False"
If Rs.State <> adStateClosed Then Rs.Close
Rs.CursorLocation = adUseClient
Rs.Open "Select * from 费用清单", Cn, 3, 2
Set DataGrid1.DataSource = Rs
DataGrid1.Refresh
End Sub
[此贴子已经被作者于2019-12-20 11:02编辑过]