VB中怎么实现调用Access中的带参数视图查询

rongdzh 2003-03-24 06:03:48
请各位大侠帮帮忙,在Access视图中建了一个带参数的查询,运行时要求输入参数的值,才能查询,请问在VB中用ADO怎么调用此查询,该怎么赋值给它?
...全文
158 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
flxa 2003-05-15
  • 打赏
  • 举报
回复
gz
chenyu5188 2003-05-15
  • 打赏
  • 举报
回复
来晚了的有分吗?!:)
zsgzsgzsg 2003-05-15
  • 打赏
  • 举报
回复
no
rongdzh 2003-05-14
  • 打赏
  • 举报
回复
zsgzsgzsg(zsg) 前辈
收到我给的分数了吗
rongdzh 2003-05-07
  • 打赏
  • 举报
回复
多个也行:)
SmileSkyNet 2003-05-07
  • 打赏
  • 举报
回复
根据我的测试好象只能使用带一个参数的存储过程
rongdzh 2003-05-07
  • 打赏
  • 举报
回复
Thank you
zsgzsgzsg 2003-03-24
  • 打赏
  • 举报
回复
'下例假定参数值为可变字符串,最大长度200
Dim mdbcn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim sn As New ADODB.Recordset
Dim Par As ADODB.Parameter,str As String
mdbcn.CursorLocation = adUseClient
mdbcn.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);UID=admin;DBQ=你的数据库"
mdbcn.Open
cmd.CommandText = "你的查询名"
cmd.CommandType = adCmdStoredProc
str = InputBox("输入参数值:")
Set Par = cmd.CreateParameter("", adVarChar, adParamInput, 200)
cmd.Parameters.Append Par
Par.Value = str
Set cmd.ActiveConnection = mdbcn
Set sn = cmd.Execute
MsgBox sn.RecordCount
Set sn = Nothing: Set cmd = Nothing
Set mdbcn = Nothing

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧