# ATLAgent Attributes Sample: Uses CCommand and CAccessor to Read Information from a Database

The ATLAgent attributes sample reads instructions from a database using the OLE DB Consumer Template classes. These instructions are used to command the Microsoft Agent control. The sample demonstrates how to use the CCommand and CAccessor classes to read information from a database and how to use the compiler COM support to control the Microsoft Agent.

The ATLAgent sample is the nonattributed version of this sample.

Security 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.

# Building and Running the Sample

#### To install the Microsoft Agent control

1. Download the Microsoft Agent control from xt >http://www.microsoft.com/msagent/ (Web links can change without notice).

2. Optionally, download the text-to-speech engine available from the same page to allow the agent to speak.

3. Choose the link to download the Microsoft Agent character animation files and download one or more of the character .acs files. By default the ATLAgent control uses the Merlin-with-sound-effects character (merlinsfx.acs). Save the files to the directory where you have installed Microsoft Agent, typically C:\Program Files\Microsoft Agent\.

#### To use the Microsoft Agent control

1. Set up a Microsoft Access data source called Agent and point the data source to the Agent.mdb file contained in the sample's directory as follows:

   - In Control Panel, select Administrative Tools, then select Data Sources (ODBC); the ODBC Data Source Administrator dialog box appears.

   - In the ODBC Data Source Administrator dialog box, go to the System DSN tab, then click Add; the Create New Data Source dialog box appears.

   - In the Create New Data Source dialog box, from the list of data sources, choose "Microsoft Access Driver (*.mdb)" then click Finish; the ODBC Microsoft Access Setup dialog box appears.

   - In the ODBC Microsoft Access Setup dialog box, in Data Source Name, type "Agent" then click Advanced; the Set Advanced Options dialog box appears.

   - In Set Advanced Options dialog box, under Options, select DefaultDir, and enter the path to the Agent.mdb file as the DefaultDir property.

2. Modify the directory locations at the beginning of AgentCtl.h if you have installed Microsoft Agent in a different directory.

3. Copy the ATLAgent project files and build the ATLAgent project.

4. Open ATLAgent.htm from the sample and click the Play button. The Agent should appear and should follow the instructions contained in the Instructions table in the Agent.mdb database.

# Attributes

This sample uses the following attributes:

coclass, db_column, db_source, db_table, default, dll, dual, helpstring, id, in, module, name, object, out, pointer_default, progid, propget, propput, retval, uuid, vi_progid

Note
Some of the samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.