ASP (vbscrtp) uses ADODB to call SQL stored procedures

Source: Internet
Author: User

Example of using ADODB to call SQL stored procedure in ASP (vbscrtp):

Set cmd = server. Createobject ("ADODB. Command") 'creates an object
Cmd. activeconnection = conn' database connection object
Cmd. commandtext = "Stored Procedure name" 'name of the stored procedure to be called
Cmd. commandtype = 4' set command to call the Stored Procedure Method
Cmd. Parameters. append cmd. createparameter ("@ PID", 30) 'Add a declaration variable
Cmd. parameters ("@ PID") = PID 'sets the declared variable value.
Set rs = cmd. Execute 'execution returns

 

Commandtype:

Commandtype = 1 (recordsource is generated by command text and usually uses SQL)

Commandtype = 2 (recordsource is a single table name)

Commandtype = 4 (recordsource is generated by the Stored Procedure)

Commandtype = 8 (the type of the generated recordsource command is unknown, and SQL is usually used)

 

Createparameter ("parameter name", type, direction, size)

Parameter Value Type:
NAME value integer function
Addbtimestamp 135 Date and Time Data Type
Addecimal 14 decimal integer
Addouble 5 Double Precision small value
Aderror 10 system error message
Adguid 72 globally unique identifier (globally unique identifier)
Addispath 9 com/OLE Automatic Object (Automation Object)
Adinteger 3 4-byte signed integer
Adiunknown 13 Com/OLE object
Adlongvarbinary 205 large 2-byte value
Adlongvarchar 201 large string value
Adlongvarwchar 203 large unencoded string
Adnumeric 131 decimal integer
Adsingle 4 single precision Floating Point decimal point
Adsmallint 2 2-byte signed integer
Adtinyint 16 1-byte signed integer
Adunsignedbigint 21 8-byte unsigned integer
Adunsignedint 19 4-byte unsigned integer
Adunsignedsmallint 18 2-byte unsigned integer
Adunsignedtinyint 17 1-byte unsigned integer
Aduserdefined 132 user-defined data type
Advariant 12 OLE object
Advarbinary 204 Double Byte variable value
Advarchar 200 character variable value
Advarchar 202 unencoded string variable value
Adwchar 130 unencoded string

 

Direction value of the parameter value:
NAME value integer function
Adparaminput 1 allows data input to this parameter
Adparamoutput 2 allows data to be output to this parameter
Adparaminputoutput 3 allows data input and output to this parameter.
Adparamreturnvalue 4 allows data to be returned from a subroutine to this parameter

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.