Adovcsp.exe Demonstrates Using Stored Procedures with ADO

Article translations Article translations
Article ID: 184968 - View products that this article applies to.
This article was previously published under Q184968
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

SUMMARY

Adovcsp.exe is a sample program that demonstrates opening keyset and forwardOnly cursors using ActiveX Data Objects (ADO) Recordsets by executing stored procedures on Microsoft 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 Download Center:
ADOVCSP.EXE
Release Date: September 17, 2003

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

The application assumes that you have a Microsoft SQL Server installed with the sample Pubs database. If this is not the case, change the following code in the openConn function:
spCON->ConnectionString = L"Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=pubs;Data Source=serverName;";
Replace Data Source=serverName with the name of your server and specify the name of your database. The sample creates two stored procedures and a table, and 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:
182831 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:
184397 HOWTO: Getting ADO Disconnected Recordsets in VBA/C++/Java

REFERENCES

For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
182389 FILE: Adovcbm.exe ADO 1.5 with #import and Getrows/Bookmarks
181733 FILE: Adovcbtd.exe #import Using UpdateBatch and CancelBatch
220152 FILE: Sample: ADOVC1 Simple ADO/VC++ Application
200122 SAMPLE: ATL2ADO returns disconnected recordset from COM to VB
229088 SAMPLE: Vcspnp.exe Demonstrates Passing SQL NULL Parameters and Reading NULL Values with ADO

Properties

Article ID: 184968 - Last Review: February 23, 2014 - Revision: 5.3
APPLIES TO
  • Microsoft SQL Server 6.5 Standard Edition
  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft ActiveX Data Objects 2.7
  • Microsoft ActiveX Data Objects 1.5
  • Microsoft ActiveX Data Objects 2.0
  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.6
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
Keywords: 
kbnosurvey kbarchive kbdownload kbdatabase kbfile kbinfo KB184968

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com