This documentation is archived and is not being maintained.

ADOSAMP Sample: Implements a Three-Tier Client/Server Application

Visual Studio 2008

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.

Security noteSecurity Note:

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To get samples and instructions for installing them:

  • On the Visual Studio Help menu, click Samples.

    For more information, see Visual Studio Samples.

  • The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.

To build and run this sample

  1. In the Control Panel, open the Administrative Tools folder and then double-click Data Sources (ODBC). If you are using either Microsoft Access or SQLServer with this sample, add a (User) DSN with a Data Source Name "HotBikes." If you are using Microsoft Access, create a database called Test.

  2. For SQLServer, provide the server name and under Options specify a Database Name, for example, HotBikesDB.

  3. Open the solution ADOSamp.sln.

  4. Add the directory containing MsADO15.dll to the Include files path in the VC++ Directories dialog box.

  5. If either OLE DB or ADO has not been installed, install it from the Visual Studio CD or DVD. It will most likely be installed in:

    \Program Files\Common Files\System\ADO\MsADO15.dll

  6. If you created a SQL Server data source for this sample in step 1, uncomment the following line in RunADO.cpp:

    //#define SQLSERVER
    

    This disables a SQL command that Microsoft Access can understand but SQLServer cannot:

    "ALTER TABLE HotBikes DROP COLUMN ID"

  7. On the Build menu, click Build Solution.

  8. On the Debug menu, click Start Without Debugging. A table will be created (deleting the existing one), and several rows will be added, deleted, and updated. A new column will be added and populated with data. In the case of Microsoft Access, a column will be deleted. The contents of the table will be displayed after each modification.

Show: