How to Build the DAO Method Samples

The DAO method samples are provided as source files in the directory Samples\dbdao InstallDirectory\DAOSDK\SAMPLESon the MSDN Library disc. You can copy, compile, and execute them in a Microsoft Visual C++ project. The method samples are the Microsoft Visual C++ equivalents of the Microsoft Visual Basic DAO method samples. In order to correspond as closely as possible to the Visual Basic samples, the Microsoft Visual C++ method samples are designed as ANSI console applications.

Examples should be simple, so common functions as defined in stdio.h are used whenever possible. When necessary, less common routines as defined in conio.h are used. DAO depends on the COleVariant and CString Microsoft Foundation Classes (MFC), and objects from these classes are used often in the samples.

The procedures for creating samples are listed below. In order to build the samples, create a dummy project in Microsoft Visual C++, and a dummy source file within that project. When you want to test a sample, copy and paste it into the dummy source file then build the project.

We suggest naming the project avatar.mdp, and the source file, avatar.cpp. (An "avatar" is the embodiment of something else. Avatar.cpp will embody each sample. Using it will conserve disk space and minimize compilation time.). This procedure assumes everything listed below is done in one session.

To create the Avatar workspace

  1. Start Microsoft Visual C++.

  2. From the File menu; select New.

  3. From New, select Project Workspace.

  4. Select Console Application.

  5. Type in a name for the project. (These examples suggest the name “avatar”.)

  6. Select Create.

To create the Avatar source file

  1. Start Microsoft Visual C++.

  2. From the File menu, select New.

  3. Select Text File from the menu and choose Save.

  4. Name the file avatar.cpp when prompted to do so and close the text file.

To configure the Avatar project, you must select the project, then specify the Tools and Build settings, and save the project.

To configure Avatar project

  1. Select the Avatar project.

  2. Choose Save.

To specify the Tools settings

  1. From the Tools menu, select the Options menu item.

  2. Choose the Directories tab.

  3. From the Show Directories For menu on the Directories tab, select Include Files.

  4. Add the DAOSDK\Include directory.

  5. On the Show Directories For: menu on the Directories tab, select Library Files.

  6. Add the DAOSDK\Lib and DAOSDK\Lib\Debug directories.

To specify the Build settings

  1. From the main Build menu, choose Settings.

  2. Select the General tab.

  3. Select the Microsoft Foundation Classes list.

  4. Select Use MFC in a Shared DLL.

  5. Select the C/C++ tab.

  6. From the Category list, select Code Generation.

  7. From the Use Run Time Library list, select the Debug Multi-threaded DLL item.

When you have finished configuring the Avatar project, you must close the Workspace.

To close the Workspace

  1. From the File menu, select Close Workspace.

  2. From the File menu, select Exit.

To Select the Library Modules

  1. Select the Link tab.

  2. On the Category menu, select General.

  3. In the Object/Library Modules text box, add ddao35d.lib. (This is the ANSI Debug module.

    Note Other choices are ddao35.lib (ANSI Release), ddao35ud.lib (Unicode Debug), and ddao35u.lib (Unicode Release).

If you cannot debug trace into dbDAO libraries, you may need to copy the debug version of the .dll or .pdb files into your Windows\System (for Win95) or Windows\System32 (for Windows NT) directory.

To rebuild the sample

  1. Copy a sample file into avatar.cpp.

  2. Build and execute the project. The word Execution will display in an MS-DOS Prompt window.