存储过程使用大全
类别: ASP教程
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")
%>
<%
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")
%>
- 上一篇: MD5不可逆加密算法的ASP实现实例
- 下一篇: ASP程序和PHP程序转换要注意的问题
-= 资 源 教 程 =-
文 章 搜 索