标题:为什么在VB的ACCESS模糊查询时出错?
只看楼主
ygxshanghai
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-3-3
结帖率:100%
 问题点数:0 回复次数:3 
为什么在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编辑过]

搜索更多相关主题的帖子: Set Sub ADODB Text Open 
2019-12-20 11:01
yingshu
Rank: 4
等 级:贵宾
威 望:10
帖 子:49
专家分:212
注 册:2018-7-24
得分:0 
Where " & Combo1.Text & "
 &去掉试试
2019-12-20 12:09
ygxshanghai
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-3-3
得分:0 
回复 2楼 yingshu
出现错误
2019-12-20 16:09
wufuzhang
Rank: 9Rank: 9Rank: 9
来 自:广州
等 级:贵宾
威 望:21
帖 子:206
专家分:1346
注 册:2017-8-9
得分:0 
回复 楼主 ygxshanghai
Rs.Open "SELECT * from 费用清单 Where " & Combo1.Text & " Like '%" & Text1.Text & "%'", Cn, 3, 2改为
Rs.Open "SELECT * from 费用清单 Where " & Combo1.Text & " Like '%" & Text1.Text & "%'", Cn, 1, 3

不经历千百遍的调试,怎能体会成功时那一刹那的喜悦。
2019-12-21 17:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-498513-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025045 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved