当我尝试从经典ASP调用MySql存储过程时,我收到此错误:
例程spAddContactUsEmail的OUT或INOUT参数5不是BEFORE触发器中的变量或NEW伪变量
这是SP(我可以从Mysql工作台成功调用):
CREATE DEFINER=`root`@`localhost` PROCEDURE `spAddContactUsEmail`(
In vcName varchar(50),
In vcPhone varchar(50),
In vcEmail varchar(50),
In txtComments text,
Out intNewID int
)
BEGIN
Insert Into contact_us (`Name`, Phone, Email, Comments, DateCreated)
Values (vcName, vcPhone, vcEmail, txtComments, now());
Set intNewID = Last_Insert_ID();
END
这是ASP代码:
Dim con
Dim cmd
Set con = Server.CreateObject("ADODB.Connection")
con.Open "connection string"
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "spAddContactUsEmail"
cmd.Parameters.Append cmd.CreateParameter("vcName", adVarChar, adParamInput, 50, "John Doe")
cmd.Parameters.Append cmd.CreateParameter("vcPhone", adVarChar, adParamInput, 50, "333-4444")
cmd.Parameters.Append cmd.CreateParameter("vcEmail", adVarChar, adParamInput, 50, "test@yahoo.com")
cmd.Parameters.Append cmd.CreateParameter("txtComments", adLongVarChar, adParamInput, Len("hey"), "hey")
cmd.Parameters.Append cmd.CreateParameter("intNewID", adInteger, adParamReturnValue)
cmd.Execute
cmd.Execute行发生错误。提前谢谢。
答案 0 :(得分:0)
将adParamReturnValue更改为adParamOutput:
<%
cmd.Parameters.Append cmd.CreateParameter("intNewID", adInteger, adParamOutput, 4)
%>