How you use the Command object largely depends on the data source, and what type of query or command statement it will accept.
ODBC provides a specific syntax for calling stored procedures. For the CommandText property of a Command object, the CommandText argument to the Execute method on a Connection object, or the Source argument to the Open method on a Recordset object, passes in a string with this syntax:
"{ [ ? = ] call procedure [ ( ? [, ? [ , … ]] ) ] }" Each ? references an object in the Parameters collection. The first ? references Parameters(0), the next ? references Parameters(1), and so on.
The parameter references are optional and depend on the structure of the stored procedure. If you want to call a stored procedure that defines no parameters, your string would look like the following:
If you have two query parameters, your string would resemble the following:
"{ call procedure ( ?, ? ) }" If the stored procedure will return a value, the return value is treated as another parameter. If you have no query parameters but you do have a return value, your string would resemble the following:
Finally, if you have a return value and two query parameters, your string would resemble the following:
"{ ? = call procedure ( ?, ? ) }"