Microsoft KB Archive/239440

From BetaArchive Wiki

Article ID: 239440

Article Last Modified on 8/15/2005



APPLIES TO

  • Microsoft Visual Studio 6.0 Service Pack 3
  • Microsoft Data Access Components 2.1 Service Pack 2
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition



This article was previously published under Q239440

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 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.

FileName Size
ATL4Acc.cpp 11 KB
EULA.txt 1.61 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: ATL4Acc

Keywords: kbinfo kbdownload kbconsumer kbfile kbsample KB239440