This article was previously published under Q184968
This article has been archived. It is offered "as is" and will no longer be updated.
Adovcsp.exe is a sample program that demonstrates opening keyset andforwardOnly 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.
The following file is available for download from the Microsoft Download Center:
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:
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 thestored procedure sp_AdoTestInOut. sp_AdoTestInOut returns all the recordswith 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 codeare only used when running the stored procedure by clicking the OpenReadbutton. Please see the source code for more details.
The Supports button obtains the schema information from the database usingthe technique and code described in the following Microsoft Knowledge Basearticle:
182831 HOWTO: Using the ADO OpenSchema Method from Visual C++
The Open DisCon button opens a disconnected recordset. This code is takenfrom the following Microsoft Knowledge Base article:
184397 HOWTO: Getting ADO Disconnected Recordsets in VBA/C++/Java
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