Adovcsp.exe Demonstrates Using Stored Procedures with ADO

ID: Q184968


The information in this article applies to:
  • Microsoft SQL Server version 6.5
  • Microsoft Visual Studio versions 6.0, 97
  • ActiveX Data Objects (ADO), versions 1.5, 2.0, 2.1


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. Click the file name below to download the file:

ADOVCSP.EXE
Release Date: May-01-1998

For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.




The application assumes that you have a local Microsoft 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, 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:
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 kbDatabase kbGrpVCDB kbGrpMDAC kbDSupport
Version : WINDOWS:1.5,2.0,2.1,6.0,97; winnt:6.5
Platform : WINDOWS winnt
Issue type : kbinfo


Last Reviewed: December 14, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.