<%
'---开始链接数据库
Dim strConnString
strConnString = "driver={SQL Server};server=songhp;uid=sa;pwd=;database=XVZDemo"
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strConnstring
'---结束链接数据库
'---开始为输入参数赋值
Dim SelectSql , SelectRs
Dim SelectID , SelectName , SelectReturn
SelectSql = "Select Max(CompanyID) From Dim_Company"
Set SelectRs = Conn.Execute(SelectSql)
SelectID = SelectRs(0)
'---结束为输入参数赋值
Dim TiggerType
TiggerType = 3
Set Cmd = Server.CreateObject("ADODB.Command")
Set Cmd.ActiveConnection = Conn
Cmd.CommandType = 4 '---声明此过程为存储过程
If TiggerType = 1 then
'---开始一个输入参数的存储过程调用
Cmd.CommandText = "TransCompany1"
Set CmdParam = Cmd.CreateParameter("@TransID",3,1)
Cmd.Parameters.Append CmdParam
Cmd("@TransID") = SelectID
Cmd.Execute
'---结束一个输入参数的存储过程调用
Elseif TiggerType = 2 then
'---开始一个输入参数,一个输出参数的存储过程调用
Cmd.CommandText = "TransCompany2"
Set CmdParamID = Cmd.CreateParameter("@TransID",3,1)
Cmd.Parameters.Append CmdParamID
Cmd("@TransID") = SelectID
Set CmdParamName = Cmd.CreateParameter("@TransName",202,2,50)
Cmd.Parameters.Append CmdParamName
Cmd.Execute
SelectName = Cmd("@TransName")
'---结束一个输入参数,一个输出参数的存储过程调用
Elseif TiggerType = 3 then
'---开始一个输入参数,一个输出参数,一个返回值的存储过程调用
Cmd.CommandText = "TransCompany3"
Set CmdParamReturn = Cmd.CreateParameter("Return_Value",3,4)
Cmd.Parameters.Append CmdParamReturn
Set CmdParamID = Cmd.CreateParameter("@TransID",3,1)
Cmd.Parameters.Append CmdParamID
Cmd("@TransID") = SelectID
Set CmdParamName = Cmd.CreateParameter("@TransName",202,2,50)
Cmd.Parameters.Append CmdParamName
Cmd.Execute
SelectName = Cmd("@TransName")
SelectReturn = Cmd("Return_Value")
'---结束一个输入参数,一个输出参数,一个返回值的存储过程调用
End if
Conn.Close
Set Conn = Nothing
Set Cmd = Nothing
Set CmdParamID = Nothing
各种存储过程使用指南
内容版权声明:除非注明,否则皆为本站原创文章。