The information in this article applies to:
SUMMARYATL2ADO.exe is a sample that demonstrates a minimal three-tiered Database Application using ADO 2.0. It also demonstrates the following:
MORE INFORMATIONThe following file is available for download from the Microsoft
Download Center. Click the file name below to download the file: Atl2ado.exeFor more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center.
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
REFERENCES
For additional information, please see the following
articles in the Microsoft Knowledge Base: Q182389 FILE: Adovcbm.exe ADO 1.5 with #import and Getrows/Bookmarks Q184968 FILE: Adovcsp.exe Demonstrates Using Stored Procedures with ADO Q186387 SAMPLE: Ado2atl.exe Returns ADO Interfaces from COM Q181733 FILE: Adovcbtd.exe #import Using UpdateBatch and CancelBatch © Microsoft Corporation 1999, All Rights Reserved. Additional query words:
Keywords : kbfile kbsample kbADO kbDatabase kbMDAC kbSDKDataAc kbVBp600 kbVC600 kbGrpMDAC |
Last Reviewed: November 25, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |