This sample implements a three-tier client/server application using ADO, ATL, and Compiler COM support.
The sample demonstrates how you can use Compiler COM support with ADO to create a client/server database application. The application creates a small database of information about motorcycles and their top speeds. The application inserts rows, deletes rows, adds a new column, and searches on top speeds greater than a specified value.
To run the sample
In Windows NT 4.0, open ODBC Data Source Administrator in Control Panel. Using either Microsoft Access or SQLServer, add a (User) DSN with Data Source Name "HotBikes" If you are using Microsoft Access, create a database called Test.
For SQLServer, provide the server name and under Options specify a Database Name, for example, HotBikesDB.
Open ADOSamp.dsw in Visual C++.
In StdAfx.h, edit the path of MsADO10.dll in the #import statement to point to the copy on your machine.
If either OLE DB or ADO has not been installed, install it from the Visual Studio CD. It will most likely be installed in:
Build ADOSamp either as an in-proc (DLL) or local (EXE) server. Registration should be automatic. However, if necessary, run:
regsvr32 ADOSamp.dll or ADOSamp.exe /RegServer
To build the client
Open RunADO.dsw in Visual C++. Near the top of RunADO.cpp is the line:
//#define SQLSERVER
Uncomment this line if you created a SQLServer data source for this sample. This disables a SQL command that Microsoft Access can understand but SQLServer cannot:
"ALTER TABLE HotBikes DROP COLUMN ID"
Run RunADO.exe. A table will be created (deleting the existing one) and several rows added, deleted, and updated. A new column is added, populated with data, and, in the case of Microsoft Access, a column is deleted.
The contents of the table are displayed after each modification.