The information in this article applies to:
SUMMARYThis article demonstrates two techniques for filling the ADO Parameters collection for a command object using a Stored Procedure. MORE INFORMATIONConsider this stored procedure, which uses input, output, and return parameters:
The ADO Parameters collection needs one object for each parameter and,
more importantly, the direction property of each parameter must match the
order of the parameters in the calling syntax.The code below demonstrates setting up the call to the stored procedure and explicitly creating the parameter objects properties: NOTE: This technique is hazardous in that if the stored procedure changes the
order or direction of parameters, this code has to be changed. There is a
much smaller alternative, which gets the same results. By just listing
the name of the stored procedure for CommandText and refreshing the
Parameters Collection, ADO automatically fills the Parameters Collection,
one for each parameter required by the stored procedure. However, one potential drawback to this
method is the overhead involved. It does require a round trip to the server to
get the parameter information, and thus there is a greater performance hit
than if you build the parameters yourself. This would be a good way to determine the correct parameters properties for a procedure. Use the information returned to set up the parameters in code as demonstrated above. This is
demonstrated in the following code:
This generates exactly the same rowset, but lets ADO fill the parameters
collection automatically and correctly (although this code correctly determines that the
second parameter is an input parameter).
Additional query words:
Keywords : kbADO150 kbADO200 kbDatabase kbVBp500 kbVBp600 kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2 kbMDAC210SP2 |
Last Reviewed: November 2, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |