各種存儲過程使用指南
各種存儲過程使用指南
<%@ Language=VBScript %>?
<%
‘---開始鏈接數據庫?
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?
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?
Set CmdParamname = Nothing?
Set CmdParamReturn = Nothing
%>
各種存儲過程使用指南