Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


More information

The following file is available for download from the Microsoft Download Center:
Release Date: September 7, 2000

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.

FileNameSize
ATL4Acc.cpp11 KB
EULA.txt1.61 KB
Readme.txt1 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.

↑ Back to the top


References

MSDN on-line help for ATL consumers

↑ Back to the top


Keywords: KB239440, kbsample, kbinfo, kbfile, kbconsumer, kbdownload

↑ Back to the top

Article Info
Article ID : 239440
Revision : 8
Created on : 8/15/2005
Published on : 8/15/2005
Exists online : False
Views : 433