Stored procedures are a set of SQL statements that are compiled for specific functions and stored in a database. So do you know the guide to using various stored procedures? Let the editor of the Foot New Technology Channel take you to learn more about it!
<%
'---Start link to the database
Dim strConnString
strConnString = "driver={SQL Server};server=songhp;uid=sa;pwd=;database=XVZDemo"
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strConnstring
'---End link database
'---Start assign values to the input parameters
Dim SelectSql , SelectRs
Dim SelectID , SelectName , SelectReturn
SelectSql = "Select Max(CompanyID) From Dim_Company"
Set SelectRs = Conn.Execute(SelectSql)
SelectID = SelectRs(0)
'---End assign value to the input parameter
Dim TiggerType
TiggerType = 3
Set Cmd = Server.CreateObject("ADODB.Command")
Set Cmd.ActiveConnection = Conn
Cmd.CommandType = 4 '--Declare this procedure as a stored procedure
If TiggerType = 1 then
'---Start a stored procedure call with input parameters
Cmd.CommandText = "TransCompany1"
Set CmdParam = Cmd.CreateParameter("@TransID",3,1)
Cmd.Parameters.Append CmdParam
Cmd("@TransID") = SelectID
Cmd.Execute
'---End a stored procedure call with input parameters
Elseif TiggerType = 2 then
'---Stored procedure call for an input parameter and an output parameter
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")
'---End a stored procedure call for an input parameter and an output parameter
Elseif TiggerType = 3 then
'---Start a stored procedure call with an input parameter, an output parameter, and a return value
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 a stored procedure call with an input parameter, an output parameter, and a return value
End if
Conn.Close
Set Conn = Nothing
Set Cmd = Nothing
Set CmdParamID = Nothing
Set CmdParamname = Nothing
Set CmdParamReturn = Nothing
%>
Through the guide to using various stored procedures introduced by the editor of the 未分New Technology Channel, I believe everyone has a certain understanding. If you need to know more related information, please continue to pay attention to the 未分New Technology Channel!