具有输入输出参数的CORE ASP调用存储过程 [英] CORE ASP call store procedure with input output parameters

查看:50
本文介绍了具有输入输出参数的CORE ASP调用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是mysql 例程(存储过程)......

This is mysql routine(store procedure)...

-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `InUser`(
IN Id INTEGER,
In UId Integer,
In UIdTo Integer,
out R_Id Integer
)
BEGIN
	IF Id = 0 THEN     
		insert into test.main
		select (SELECT COALESCE(max(test.main.Id),0)+1 FROM test.main) as id,UId as uid;

		insert into test.main
		select (SELECT max(test.main.Id) FROM test.main) as id,UIdTo as uid;  
		
		set R_Id = (select max(id) from test.main);
	Else
		insert into test.main
		select test.main.Id as id,UIdTo as uid; 

		set R_Id = (select max(test.main.id) from test.main);
	End If;
END







ASP代码如下...




ASP CODE is as below...

<html>
<body>

<form >
 <%
 MsgBox "Hello, World!"
 on error resume next
        Set OBJdbConnection1 = Server.CreateObject("ADODB.Connection")
        OBJdbConnection1.ConnectionTimeout = Session("ConnectionTimeout")
        OBJdbConnection1.CommandTimeout = Session("CommandTimeout")
        OBJdbConnection1.Open  Session("ConnectionString")

     dim Uid,Id
     Uid = 1'request.form("Uid")
     Id = 0'request.form("Id")

     Set SQLStmt1 = Server.CreateObject("ADODB.Command")
     Dim sqlstr, result
     sqlstr = "InUser";


     SQLStmt1.CommandText = sqlstr
     SQLStmt1.CommandType = adCmdStoredProc
     Set SQLStmt1.ActiveConnection = OBJdbConnection1

    SQLStmt1.Parameters.Append(SQLStmt1.createParameter("Id",adInteger,adParamInput,50,Id))
    SQLStmt1.Parameters.Append(SQLStmt1.createParameter("UId", adInteger,adParamInput,50,Session("UId")))
    SQLStmt1.Parameters.Append(SQLStmt1.createParameter("ToUId",adInteger,adParamInput,50,Uid))
    SQLStmt1.Parameters.Append(SQLStmt1.createParameter("R_id",adInteger,adParamOutput,50,Id))


     result = OBJdbConnection.Execute(sqlstr)
     id=SQLStmt1.Parameters("R_id").value
     response.write(id)
    
%>

</form >
</body>
</html>







没有显示错误或消息框

而不是呼叫sp



请帮助




not showing error or messagebox
and not calling sp

please help

推荐答案

创建 DEFINER =` root` @`localhost` PROCEDURE `InUser`(
IN Id INTEGER,
UId整数中,
UIdTo整数中,
out R_Id整数

BEGIN
IF Id = 0 那么
insert < span class =code-keyword> into test.main
select SELECT COALESCE (max(test.main.Id), 0 )+ 1 FROM test.main) as id,UId as uid;

insert into test.main
选择 SELECT max(test.main.Id) FROM test .main) as id,UIdTo as uid;

set R_Id =( select max(id)来自 test.main);
Else
insert into test.main
选择 test.main.Id as id,UIdTo as uid;

set R_Id =( select max(test.main.id)< span class =code-keyword>来自 test.main);
结束 如果;
END
CREATE DEFINER=`root`@`localhost` PROCEDURE `InUser`( IN Id INTEGER, In UId Integer, In UIdTo Integer, out R_Id Integer ) BEGIN IF Id = 0 THEN insert into test.main select (SELECT COALESCE(max(test.main.Id),0)+1 FROM test.main) as id,UId as uid; insert into test.main select (SELECT max(test.main.Id) FROM test.main) as id,UIdTo as uid; set R_Id = (select max(id) from test.main); Else insert into test.main select test.main.Id as id,UIdTo as uid; set R_Id = (select max(test.main.id) from test.main); End If; END







ASP代码如下...




ASP CODE is as below...

<html>
<body>

<form >
 <%
 MsgBox "Hello, World!"
 on error resume next
        Set OBJdbConnection1 = Server.CreateObject("ADODB.Connection")
        OBJdbConnection1.ConnectionTimeout = Session("ConnectionTimeout")
        OBJdbConnection1.CommandTimeout = Session("CommandTimeout")
        OBJdbConnection1.Open  Session("ConnectionString")

     dim Uid,Id
     Uid = 1'request.form("Uid")
     Id = 0'request.form("Id")

     Set SQLStmt1 = Server.CreateObject("ADODB.Command")
     Dim sqlstr, result
     sqlstr = "InUser";


     SQLStmt1.CommandText = sqlstr
     SQLStmt1.CommandType = adCmdStoredProc
     Set SQLStmt1.ActiveConnection = OBJdbConnection1

    SQLStmt1.Parameters.Append(SQLStmt1.createParameter("Id",adInteger,adParamInput,50,Id))
    SQLStmt1.Parameters.Append(SQLStmt1.createParameter("UId", adInteger,adParamInput,50,Session("UId")))
    SQLStmt1.Parameters.Append(SQLStmt1.createParameter("ToUId",adInteger,adParamInput,50,Uid))
    SQLStmt1.Parameters.Append(SQLStmt1.createParameter("R_id",adInteger,adParamOutput,50,Id))


     result = OBJdbConnection.Execute(sqlstr)
     id=SQLStmt1.Parameters("R_id").value
     response.write(id)
    
%>

</form >
</body>
</html>







没有显示错误或消息框

而不是打电话给



请帮忙




not showing error or messagebox
and not calling sp

please help


这篇关于具有输入输出参数的CORE ASP调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆