Article ID: 200122 - View products that this article applies to.
This article was previously published under Q200122
This article has been archived. It is offered "as is" and will no longer be updated.
ATL2ADO.exe is a sample that demonstrates a minimal three-tiered Database Application using ADO 2.0. It also demonstrates the following:
The following file is available for download from the Microsoft Download Center:
Atl2ado.exeFor additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591Microsoft 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.
(http://support.microsoft.com/kb/119591/EN-US/ )How to Obtain Microsoft Support Files from Online Services
FileName Size --------------------------------------------------------- adostudent.mdb 72 readme.txt 491 helper.idl 21 R1ADOdrsExe.aps 4332 R1ADOdrsExe.cpp 4447 R1ADOdrsExe.dsp 12760 R1ADOdrsExe.dsw 545 R1ADOdrsExe.h 84 R1ADOdrsExe.idl 756 R1ADOdrsExe.rc 2941 R1ADOdrsExe.rgs 185 R1ADOdrsExeps.def 253 R1ADOdrsExeps.mk 502 r1DisRS.cpp 473 r1DisRS.h 891 r1DisRS.rgs 645 resource.h 549 StdAfx.cpp 315 StdAfx.h 1091
ATL2ADO.exe is a sample that demonstrates a minimal three-tiered Database Application using ADO 2.0. An ATL server in the middle tier returns a read/write disconnected recordset to a Visual Basic client for presentation. The Visual Basic client can change the data and send it to the server to be updated. The business logic is located in the COM server. The ATL COM server updates the Database tier.
In addition, ATL2ADO.exe demonstrates how to create a simple ATL COM object that returns a disconnected ADO recordset. The sample includes a Visual Basic client that uses the ADO _Recordset returned from the ATL COM Server. The Visual Basic client can change the record data and use the UpdateBat method provided by the server to save changes to the database. After extracting the files, build the Visual C++ project first to register the COM Objects and then use Visual Basic 6.0 to build the client program. The client and server can be distributed to different computers on the network.
The sample also shows how to build the proxy/stub DLL that is used to marshal the recordset. The sample includes an Access .mdb file that you can use with Access and SQL to build the student table that you can use with SQL Server. Use the following query with the GradYear parameter supplied by the Visual Basic client:
Build the Visual C++ project with Visual C++ 6.0 to create and register the server and the proxy/stub DLL. Build the Visual Basic project with Visual Basic version 6.0. You can build the server on one computer and the client on another computer on the same network. Copy the included Access database, ADOStudent.mdb, to C:\test (or change the connection string in the source file).
The sample server is created with the ATL COM AppWizard as an .exe server. A simple object ( r1DisRS ) is inserted. You need to make the following additions to the .idl file:
ADO is imported through the file stdAfx.h with the following two lines:
From the Project Settings menu, click Post Build tab, add the "build & Reg Proxy/Stub DLL" as the description, and add the following two commands:
This allows Visual C++ to automatically build and register the proxy/stub DLL. You must also specify Win32 Debug on the build bar.
The Visual Basic client sets the recordset property MarshalOptions to adMarshalModifiedOnly so that only the modified records are marshaled back to the server. Note that once you click commandSave, the recordset is trimmed to just the modified records. You must click CommandGetRS to retrieve the entire recordset back to the Visual Basic client.
You can build the Visual C++ project on Computer1 and build the Visual Basic client on Computer2. To specify the remote computer (Computer1 in the following example) use the following Visual Basic syntax:
Create Student Table on SQL Server
For additional information, please see the following articles in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/182389/EN-US/ )FILE: Adovcbm.exe ADO 1.5 with #import and Getrows/Bookmarks
(http://support.microsoft.com/kb/184968/EN-US/ )FILE: Adovcsp.exe Demonstrates Using Stored Procedures with ADO
(http://support.microsoft.com/kb/186387/EN-US/ )SAMPLE: Ado2atl.exe Returns ADO Interfaces from COM
(http://support.microsoft.com/kb/181733/EN-US/ )FILE: Adovcbtd.exe #import Using UpdateBatch and CancelBatch
Article ID: 200122 - Last Review: February 23, 2014 - Revision: 2.4
Contact us for more help
Connect with Answer Desk for expert help.