VB如何调用mysql的存储过程

liuynm 2008-05-03 04:55:18
比如数据库里有glry这样的一个表,定义如下:
create table if not exists glry (
id int auto_increment not null ,
GONGHAO char(6) not null,
primary key (id) )
我建了如下的存储过程:
create procedure a(in b char(6))
select * from glry where GONGHAO=b
在VB中我怎么条用这个存储过程?
按照网上的资料我这样做的,建立好连接然后
Dim objCmd As ADODB.Command
Dim objPara1 As ADODB.Parameter
Set objCmd = New ADODB.Command
Set objPara1 = New ADODB.Parameter
With objCmd
.ActiveConnection = gobjConn '已建立的连接
.CommandText = "a"
.CommandType = adCmdStoredProc
End With
objPara1.Name = "@b"
objPara1.Type = adChar
objPara1.Size = 6
objPara1.Direction = adParamInput
objPara1.Value = "000001"
objCmd.Parameters.Append objPara1
Set gobjRs = objCmd.Execute
Set objCmd = Nothing
Set gobjRs = Nothing
在红字显示处出错,出错信息在word里存放,好几天了,实在是解决不了了,高手,帮帮我吧。
另外这个“@”是什么意思?
有成功的VB连接mysql的例子也好呀。
...全文
135 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ACMAIN_CHM 2010-01-18
  • 打赏
  • 举报
回复
.CommandText = "call a(?)"
feixiangzaici 2010-01-18
  • 打赏
  • 举报
回复
哎,哥们,可要看清楚我的帖子呀,这样是可是同样也报错呀,

呵呵,仔细看看呀

谢谢
feixiangzaici 2010-01-18
  • 打赏
  • 举报
回复
给你一个成功连接mysql的字符串:

ConnData_base = "DRIVER={MySQL ODBC 3.51 Driver};" _
& "SERVER=localhost;" _
& "Port=3306;" _
& "DATABASE=ch_base_data;" _
& "UID=ch;PWD=123456; OPTION=3;stmt=SET NAMES GB2312"

feixiangzaici 2010-01-18
  • 打赏
  • 举报
回复
Hi,liuynm,伙计

你的问题解决了吗

怎么不见你出现呀

说说答案呀

reality 2008-05-04
  • 打赏
  • 举报
回复
这里显示的语法错误{call b('000001')}
你所建的存储过程叫 a 这里调用的是b,不是参数 ,不是过程名字。
call a('000001') 试试。
wwwwb 2008-05-04
  • 打赏
  • 举报
回复
在MYSQL中是否可以调用,似乎应该加上BEGIN END吧
liuynm 2008-05-04
  • 打赏
  • 举报
回复
错误提示是:实时错误‘-2147217900 (80040e14)’
[MySQL][ODBC 3.51 Driver][mysqlld-5.0.24-community-nt]you have an error in your SQL syntax:check the manual that corresponds to your MySQL server version for the right syntax to use near'{call b('000001')}' at line 1
liuynm 2008-05-04
  • 打赏
  • 举报
回复
不好意思,敲错了,就是错误提示是:
实时错误‘-2147217900 (80040e14)’
[MySQL][ODBC 3.51 Driver][mysqlld-5.0.24-community-nt]you have an error in your SQL syntax:check the manual that corresponds to your MySQL server version for the right syntax to use near'{call a('000001')}' at line 1

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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