Get the App
SLTechnology News&Howtos  ›  Development  › 

How ado calls stored procedures

Shulou Source: shulou.com Published: 2022-06-02 08:12:46 10月04日 Update

Editor to share with you how ado calls stored procedures, I hope you will learn something after reading this article. Let's discuss it together.

You can install the ADO call stored procedure. But it doesn't have as many functions as Oracle or Microsoft. And, of course, Data Direct has a local data provider for Oracle. Can be installed in Visual Studio. But it doesn't have as many functions as Oracle or Microsoft.

Calling stored procedures in ADO has always been a perplexing problem. In fact, the method of calling stored procedures by ADO has been mentioned in many books, and the standard practice is to follow these steps:

1. Generate and initialize a _ CommandPtr object

2. Generate the parameters needed to call the stored procedure, all of which are _ ParameterPtr objects

3. In order, the Append method of _ CommandPtr will be used to provide parameters to the stored procedure (including input parameters and output parameters)

4. Specify the ADO connection that needs to be used for the _ CommandPtr object

5. Use the Execute method of _ CommandPtr to call the stored procedure

6. Get the value of the return parameter (if any) from the result. I will not describe the specific process in detail here, but I would like to take a look at the code attached to this article. Here I would like to explain some of my experience when calling stored procedures using ADO.

1. About CreateParameter function

The prototype of this function is CreateParameter (Name, Type, Direction, Size, Value), where Name is the name of the parameter, which can be specified or not specified.

Type is a DataTypeEnum value that specifies the category of parameters, such as adInteger (integer), adChar (string / string type), etc. ADO call stored procedure Direction is a ParameterDirectionEnum value, whose values are adParamInput, adParamInputOutput, adParamOutput, adParamReturnValue, adParamUnknown;Size are values of type Long, indicating the * length of the parameter calculated in bytes, for example, for int type, the value can be taken as sizeof (int)

For long type, the value can be taken as sizeof (long), ADO calls stored procedure for string type, you can use the length of the string; Value is a value of type variant, which is the value of this parameter. It should be noted here that the Type parameters, Direction parameters, and Size parameters must match the parameters defined by the stored procedure.

For example, if you have the following stored procedure:

CREATE PROCEDURE SMS_Proc_Handle_All (@ UserID Integer, @ SourAddr Varchar (15), @ DestAddr varchar (5000), @ AvValue Single output, @ ReturnInfo varchar (100) output has finished reading this article. I believe you have some understanding of "how to call stored procedures by ado". If you want to know more about it, welcome to follow the industry information channel. Thank you for reading!

Tags: Procedures parameters storage characters strings objects methods functions functions articles types length generation code practices prototypes names bytes finished instructions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information Redmi vpn NVidia