明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

各種存儲(chǔ)過程使用向?qū)?/h1>

[摘要]<%@ Language=VBScript %><%'---開始鏈接數(shù)據(jù)庫Dim strConnStringstrConnString = "driver=SQL Server;server=songhp;uid=sa;pwd=;database=XVZDemo...

<%@ Language=VBScript %>
<%

'---開始鏈接數(shù)據(jù)庫
Dim strConnString
strConnString = "driver={SQL Server};server=songhp;uid=sa;pwd=;database=XVZDemo"
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strConnstring
'---結(jié)束鏈接數(shù)據(jù)庫

'---開始為輸入?yún)?shù)賦值
Dim SelectSql , SelectRs
Dim SelectID , SelectName , SelectReturn
SelectSql = "Select Max(CompanyID) From Dim_Company"
Set SelectRs = Conn.Execute(SelectSql)
SelectID = SelectRs(0)
'---結(jié)束為輸入?yún)?shù)賦值

Dim TiggerType
TiggerType = 3

Set Cmd = Server.CreateObject("ADODB.Command")
Set Cmd.ActiveConnection = Conn
Cmd.CommandType = 4   '---聲明此過程為存儲(chǔ)過程

If TiggerType = 1 then
 
 '---開始一個(gè)輸入?yún)?shù)的存儲(chǔ)過程調(diào)用
 Cmd.CommandText = "TransCompany1"
 
 Set CmdParam = Cmd.CreateParameter("@TransID",3,1)
 Cmd.Parameters.Append CmdParam
 Cmd("@TransID") = SelectID
 Cmd.Execute
 '---結(jié)束一個(gè)輸入?yún)?shù)的存儲(chǔ)過程調(diào)用
 
Elseif TiggerType = 2 then

 '---開始一個(gè)輸入?yún)?shù),一個(gè)輸出參數(shù)的存儲(chǔ)過程調(diào)用
 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")
 '---結(jié)束一個(gè)輸入?yún)?shù),一個(gè)輸出參數(shù)的存儲(chǔ)過程調(diào)用

Elseif TiggerType = 3 then

 '---開始一個(gè)輸入?yún)?shù),一個(gè)輸出參數(shù),一個(gè)返回值的存儲(chǔ)過程調(diào)用
 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")
 '---結(jié)束一個(gè)輸入?yún)?shù),一個(gè)輸出參數(shù),一個(gè)返回值的存儲(chǔ)過程調(diào)用

End if

Conn.Close
Set Conn = Nothing
Set Cmd = Nothing
Set CmdParamID = Nothing
Set CmdParamname = Nothing
Set CmdParamReturn = Nothing

%>