The Append parameter method calls the stored procedure append parameter through the CreateParameter method, which is used to specify the property to create a new Parameter object. The specific syntax is as follows: Set parameter = command. CreateParameter (Name, Type, Direction, Size, Value) · Name Optional, string that represents the Parameter object name. Type optional, long integer value that specifies the Parameter object data type. Direction optional, long integer value specifying the Parameter object type. The Size is an optional, Long value that specifies the maximum length of the parameter value, in characters or bytes. • Value Optional, Variant, specifying the Parameter object value. The main difference between this method and the above method is that the method of appending parameters, when passing parameters to the stored procedure, first creates the parameters for the stored procedure through the CreateParameter method, and then appends the created parameters to the Parameters collection through the Append method. The key code is still the example of a stored procedure Doc_procname call: Dim Mrst as ADODB. The recordset ' Recordset object represents the complete collection of records from the underlying table or command execution results. Dim PRM as ADODB. The Parameter ' Parameter object represents a parameter or parameter associated with a command object that is based on a parameterized query or stored procedure. Adoconn. ConnectionString = adodc1.connectionstring adoconn. Openset Adocomm. ActiveConnection = adoconn Adocomm.commandtext = "Doc_procname" Adocomm.commandtype = adCmdStoredProc Set PRM = Adocomm. CreateParameter ("Parameter1", Adtinyint, adParamInput,, "1") Adocomm. Parameters.Append prmset PRM = Adocomm. CreateParameter ("Parameter2", Adinteger, adParamOutput) Adocomm. Parameters.Append Prmset MRst = Adocomm. Executereturnvalue = Adocomm. Parameters (0)
ADODB calling stored procedures