ASP中调用带输出参数的存储过程
ASP中使用带输出参数的存储过程的例子
******************************************
cmd.Parameters.Append cmd.CreateParameter("@Name",200,2,20)
//200表示字符型参数,2表示输出型,(20应该表示长度)
cmd.Parameters.Append cmd.CreateParameter("@ID",20,1)
cmd("@ID")=ClerkID
//20表示数字型参数,1表示输入型参数
//以上测试通过中程序截取
******************************************
<%
set conn=server.CreateObject("adodb.connection")
set cmd=server.CreateObject("adodb.command")
strconn="driver={sql server};server=192.168.1.99;uid=sa;pwd=sasa;database=test"
conn.Open strconn
set cmd.ActiveConnection=conn
cmd.CommandType=4
cmd.CommandText = "prc_InsertErrortest"
cmd.Parameters.Append cmd.CreateParameter("@VTalk_Card",20,1,,100) '20是adInteger的顺序号,不能用asInteger直接代替,否则出错,其他类型也一样
'cmd("@VTalk_Card")=10
cmd.Parameters.Append cmd.CreateParameter("@WP_Card",20,1,,100)
'cmd("@WP_Card")=10
cmd.Parameters.Append cmd.CreateParameter("@nret",20,3,,0)
'cmd("@nret")=0
cmd.Execute()
bbb=cmd("@nret")
response.Write bbb
%>
<!-- 存储过程的定义如下:
CREATE proc prc_InsertErrortest
(
@Talk_Card int,
@WP_Card int,
@nret int out
)
as
insert into T_Error(VTalk_Card,WP_Card,FillDate) values(@VTalk_Card,@WP_Card,getdate())
set @nret=10
-->
***********************
Asp 调用dll
set obj = Server.CreateObject("工程名.类名")
vb 和vc都这么调用。delphi应该也一样吧~`
先注册dll
Regsvr32.exe dll的绝对路径
********************
***************************
1,调用没有参数的存储过程
<%
set conn=server.CreateObject("adodb.connection")
set cmd=server.CreateObject("adodb.command")
strconn="dsn=pubs;uid=sa;pwd"
conn.Open strconn
set cmd.ActiveConnection=conn
cmd.CommandText="{call nono}"
'set rs=cmc.exe 或者cmd.execute
set rs=cmd.Execute()
%>
2,一个输入的参数的存储过程
<%
set conn=server.CreateObject("adodb.connection")
set cmd=server.CreateObject("adodb.command")
strconn="dsn=pubs;uid=sa;pwd"
conn.Open strconn
set cmd.ActiveConnection=conn
cmd.CommandText="{call oneinput(?)}"
cmd.Parameters.Append cmd.CreateParameter("@aaa",adInteger ,adParamInput )
cmd("@aaa")=100
cmd.Execute()
%>
3,一个输入参数和一个输出的参数
<%
set conn=server.CreateObject("adodb.connection")
set cmd=server.CreateObject("adodb.command")
strconn="dsn=pubs;uid=sa;pwd"
conn.Open strconn
set cmd.ActiveConnection=conn
cmd.CommandText = "{call oneinout(?,?)}"
cmd.Parameters.Append cmd.CreateParameter("@aaa",adInteger,adParamInput)
cmd("@aaa")=10
cmd.Parameters.Append cmd.CreateParameter("@bbb",adInteger,adParamOutput)
cmd.Execute()
bbb=cmd("@bbb")
%>
4,一个输入参数,一个输出参数,和一个返回值
<%
set conn=server.CreateObject("adodb.connection")
set cmd=server.CreateObject("adodb.command")
strconn="dsn=pubs;uid=sa;pwd"
conn.Open strconn
set cmd.ActiveConnection=conn
cmd.CommandText="{?=call onereturn(?,?)}"
cmd.Parameters.Append cmd.CreateParameter("@return_value",adInteger,adParamReturnValue )
cmd.Parameters.Append cmd.CreateParameter("@aaa",adInteger,adParamInput )
cmd("@aaa")=10
cmd.Parameters.Append cmd.CreateParameter("@bbb",adInteger,adParamOutput)
cmd.Execute()
bbb=cmd("@bbb")
rrr=cmd("@return_value")
%>