Home > Database > Mysql Tutorial > mysql-VB 读取 MySql 存储过程返回值

mysql-VB 读取 MySql 存储过程返回值

WBOY
Release: 2016-06-06 09:44:33
Original
981 people have browsed it

mysql存储过程vb

-- 我定义的存储过程如下,很简单的一个过程,并且在Cmd命令里面运行是正常的。
USE appraisesystem;
DROP procedure IF EXISTS protest;

DELIMITER $$
USE appraisesystem$$
CREATE DEFINER=root@% PROCEDURE protest(Word varchar(100),out lens int)
BEGIN
set lens=length(Word);
END$$

DELIMITER ;
-- 读入一个字符串,返回它的长度,就是这个简单过程
-- appraisesystem 是数据库名称;protest 是存储过程名称;
-- 然后我在 VB 里面调用

Private Sub Command2_Click()
Dim Cnn As New ADODB.Connection
Call MySqlConnect("appraisesystem", Cnn) '连接数据库的自定义过程
Dim Cmd As New ADODB.Command
Cmd.ActiveConnection = Cnn

Cmd.CommandText = "protest"
Cmd.CommandType = adCmdStoredProc

Dim Wd As New ADODB.Parameter
Dim ln As New ADODB.Parameter

Dim TestWord As String
TestWord = "hello"
Set Wd = Cmd.CreateParameter("Wd", adVarChar, adParamInput, 100, TestWord)
Set ln = Cmd.CreateParameter("ln", adInteger, adParamOutput)

Cmd.Parameters.Append Wd
Cmd.Parameters.Append ln

Cmd.Prepared = True
Cmd.Execute

MsgBox ln.Value
End Sub

-- MySqlConnect 是VB里面一个用来连接数据库的过程,这个是没有问题的
-- 运行后的问题提示如下:

[mysql]...OUT or INOUT argument 2 for routine appraisesystem.protest is not a variable or NEW pseudo-variable in BEFORE trigger
请那为高手帮忙给看看是哪里错了,我总觉得是参数的问题,但是就是搞不定

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template