1. This is also the simplest method. Two input parameters have no return value:
Set connection = server. createobject ("adodb. connection ")
Connection. open someDSN
Connection. Execute "procname varvalue1, varvalue2"
'Clear all objects as nothing and release resources
Connection. close
Set connection = nothing
2. If you want to return the Recordset:
Set connection = server. createobject ("adodb. connection ")
Connection. open someDSN
Set rs = server. createobject ("adodb. recordset ")
Rs. Open "Exec procname varvalue1, varvalue2", connection
'Clear all objects as nothing and release resources
Rs. close
Connection. close
Set rs = nothing
Set connection = nothing
3 none of the above two methods can return values (except for Recordset). To obtain the return value, use the Command method.
First, there are two return values. One is to directly return a value in the stored procedure, just like the return values of C and VB functions;
The other is that multiple values can be returned. The variable names for storing these values must be specified in the call parameters first.
In this example, we need to process multiple parameters, input parameters, output parameters, return record sets, and a direct return value (enough ?)
The stored procedure is as follows:
Use pubs
GO
-- Create a stored procedure
Create procedure sp_PubsTest
-- Define three parameter variables. Note that the third parameter is used for output.
@ Au_lname varchar (20 ),
@ IntID int,
@ IntIDOut int OUTPUT
AS
SELECT @ intIDOut = @ intID + 1
SELECT *
FROM authors
WHERE au_lname LIKE @ au_lname + '%'
-- Returns a value directly.
RETURN @ intID + 2
The asp program that calls the stored procedure is as follows:
<% @ Language = VBScript %>
<%
Dim CmdSP
Dim adoRS
Dim adCmdSPStoredProc
Dim adParamReturnValue
Dim adParaminput
Dim adParamOutput
Dim adInteger
Dim iVal
Dim oVal
Dim adoField
Dim adVarChar
'These values are predefined constants in VB and can be called directly, but they are not predefined in VBScript.
AdCmdSPStoredProc = 4
AdParamReturnValue = 4
AdParaminput = 1
AdParamOutput = 2
AdInteger = 3
AdVarChar = 200
IVal = 5
OVal = 3
'Create a command object
Set CmdSP = Server. CreateObject ("ADODB. Command ")
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service