Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

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

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 intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To get samples and instructions for installing them:

To access samples from Visual Studio

  • On the Help menu, click Samples.

    By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.

  • For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.

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:
© 2015 Microsoft