Adovcsp.exe Demonstrates Using Stored Procedures with ADO

ID: Q184968


The information in this article applies to:


SUMMARY

Adovcsp.exe is a sample program that demonstrates opening keyset and forwardOnly cursors using ADO Recordsets by executing stored procedures on MS SQL Server. It also shows how to open a disconnected record set. The sample uses the Visual C++ #import feature and demonstrates ADO Recordset GetState(), Parameters GetName() and GetValue(), and many other Recordset, Command and Connection methods.


MORE INFORMATION

The following file is available for download from the Microsoft Software Library:

Adovcsp.exe
Release Date: May-01-1998

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online Services


The application assumes that you have a local MS SQL Server installed with the pubs database. If this is not the case, change the code in the openConn() function:

   _bstr_t  bsCon("driver={sql server};server=(local); Database=pubs;
   UID=sa;PWD=;"); 
Replace server=(local) with the name of your server and specify the name of your database. The sample creates two stored procedures and a table, then drops them when the application exits.

The OpenRd method takes an input parameter (GradYear) and passes it to the stored procedure sp_AdoTestInOut. sp_AdoTestInOut returns all the records with GradYear >= to the parameter passed. It returns an output parameter, the number of records returned and also returns a parameter (the max GradYear). The student table created is based on the Student table of the Student Enrollment database that ships with Visual C++.

In this sample, the text boxes to show the Output parameter and Return code are only used when running the stored procedure by clicking the OpenRead button. Please see the source code for more details.

The Supports button obtains the schema information from the database using the technique and code described in the following Microsoft Knowledge Base article:
Q182831 HOWTO: Using the ADO OpenSchema Method from Visual C++
The Open DisCon button opens a disconnected recordset. This code is taken from the following Microsoft Knowledge Base article:
Q184397 HOWTO: Getting ADO Disconnected Recordsets in VBA/C++/Java
FileName Size
adx.ico 2KB
adx.rc2 1KB
adosp.ncb 49KB
adosp.opt 48KB
adoSP2.dsp 5KB
adosp2.dsw 1KB
adosp2.ncb 361KB
adosp2.opt 52KB
adx.aps 37KB
adx.clw 3KB
adx.cpp 2KB
adx.h 2KB
adx.rc 8KB
adxDlg.h 4KB
adxDlg.cpp 27KB
readme.txt 3KB
resource.h 2KB
StdAfx.cpp 1KB
StdAfx.h 2KB


REFERENCES

For more information, please see the following articles in the Microsoft Knowledge Base:

Q182389 FILE: Adovcbm.exe ADO 1.5 with #import and Getrows/Bookmarks

Q181733 FILE: Adovcbtd.exe #import Using UpdateBatch and CancelBatch

Additional query words: kbdse


Keywords          : kbfile 
Version           : WINDOWS:1.5,97; winnt:6.5
Platform          : WINDOWS winnt 
Issue type        : kbinfo 

Last Reviewed: April 1, 1999