How to use the Visual C++ ATL Consumer templates to perform a distributed query (198485)
The information in this article applies to:
- Microsoft Visual C++ 2005 Express Edition
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
- Microsoft SQL Server 7.0
This article was previously published under Q198485 Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code. Microsoft Visual C++ 2005 supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. SUMMARY The sample below is an OLE DB Consumer Application that
demonstrates how to perform a distributed query with Visual C++ 6.0 ATL
Consumer templates to retrieve data from SQL Server (using SQLOLEDB Provider)
and Microsoft Access Database (using Jet OLEDB Provider) by joining the two
NorthWind databases.
The application extracts the PRODUCT ID and
PRODUCT NAME from a Products table stored in NorthWind Jet database, joins it
with the Products table stored in NorthWind Microsoft SQL Server 7.0 Database,
and applies SQL Server ORDER BY to sort the final results.
Briefly,
create a .cpp file using the code given below in Visual C++ 6.0 and
compile/build from the Build menu (it will prompt for creating a new
workspace--this should build and run without adding new code). Change the
initialization properties to connect to your SQL 7.0 server. In the OpenRoswset
call, change the path to point to NorthWind ("nwind.mdb") sample database on
your machine. The sample database is installed by OLE DB SDK, Access, and
Visual Basic. REFERENCES For more details on setting up and using distributed
queries, see "sp_addlinkedserver," "OpenQuery," "OpenRowset," and
related topics in SQL Server 7.0 Books Online. To learn more about
the Accessor used in the code above, run the ATL Consumer Wizard on SQL Server
7 NorthWind database, Products Table.
For more information about the requirements to add OLE DB template support to Visual C++, click the following article number to view the article in the Microsoft Knowledge Base:
190959
OLE DB Consumer Template Wizard requires ATL project
For more information, see the support webcast at the
following Microsoft Web site:
Modification Type: | Major | Last Reviewed: | 1/9/2006 |
---|
Keywords: | kbDatabase kbDTL kbhowto KB198485 kbAudDeveloper |
---|
|