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