ATL4Acc.exe: Calling SQL 7 Parameterized Stored Procedures Using ATL OLE DB Consumer Accessors

ID: Q239440


The information in this article applies to:
  • Microsoft Visual Studio, Enterprise Edition 6.0 SP3
  • Microsoft Data Access Components version 2.1 SP2


SUMMARY

Active Template Library (ATL) OLE DB Consumer libraries provide four types of accessors template classes to retrieve or manipulate data. ATL4Acc.exe is a sample that demonstrates data retrieval from a Microsoft SQL Server version 7 stored procedure using ATL OLE DB consumer accessor classes:

  • CAccessor


  • CManualAccessor


  • CDynamicParameterAccessor


Note that the CDynamicAccessor does not support parameterized queries but has been included as an exercise.


MORE INFORMATION

The following file is available for download from the Microsoft Software Library. Click the file name below to download the file:

ATL4Acc.exe
Release Date: August-23-1999

For more information about how to download 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


FileName Size
ATL4Acc.cpp 11 KB
Readme.txt 1 KB


Steps to Run the Application

  1. Create an empty Win32 console application.


  2. Insert ATL4Acc.cpp into the project.


  3. Create a DSN, called LocalServer, that points to the SQL Server 7.0 pubs sample database using the SQL Server ODBC driver.


  4. Create the stored procedure sp_Authors in the SQL Server pubs database using Query Analyzer. The stored procedure code is given in the ATL4Acc.cpp file.


  5. Compile and run the application.


Data Retrieval for each Accessor

  • The CAccessor class uses the Storage class CAuthors to create the accessor. It uses the BEGIN_COLUMN_MAP and BEGIN_PARAM_MAP macros to build column and parameter accessors respectively.


  • The CManualAccessor class builds the parameters and data column accessors dynamically. It makes use of SQL Server 7 database schema to build its data column and parameter accessors and executes the query. It retrieves data column information using the CColumns class that contains data pertaining to the DBSCHEMA_COLUMNS schema. The parameter accessor is built using the CProcedureParameters class that pertains to DBSCHEMA_PROCEDURE_PARAMETERS schema.


  • The CDynamicParameterAccessor class uses its BindParameteres, SetData and GetData member functions to build its parameter accessor.


  • The CDynamicAccessor class does not support parameterized query.



REFERENCES

MSDN on-line help for ATL consumers

Additional query words:

Keywords : kbfile kbsample kbATL kbDatabase kbOLEDB kbVC kbConsumer kbVS600sp3 kbGrpVCDB kbDSupport kbMDAC210SP2
Version : WINDOWS:2.1 SP2,6.0 SP3
Platform : WINDOWS
Issue type :


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