Sequence of Operations for Creating Database Applications

OverviewHow Do ITutorial

The following table shows your role and the framework's role in writing database applications.

Creating Database Applications

Task You do The framework does
Decide whether to use the MFC DAO classes or the MFC ODBC classes. See Should I use DAO or ODBC in Visual C++ Programmer's Guide. For general information, see the article Databases: Overview. The framework supplies two sets of database classes, one based on Data Access Objects (DAO) and the Microsoft Jet database engine, and the other based on ODBC.
Create your skeleton application with database options. Run AppWizard. Select options on the database options page. If you choose one of the options that creates a record view, also specify a data source and table name(s) and/or query name(s). AppWizard creates files and specifies the necessary includes. Depending on whether you specify DAO or ODBC and which other options you specify, the files can include a recordset class.
Design your database form(s). Use the Visual C++ dialog editor to place controls on the dialog template resources for your record view classes. AppWizard creates an empty dialog template resource for you to fill in.
Create additional record view and recordset classes as needed. Use ClassWizard to create the classes and the dialog editor to design the views. ClassWizard creates additional files for your new classes.
Create recordset objects as needed in your code. Use each recordset to manipulate records. Your recordsets are based on the classes derived from or with the wizards. If you're using DAO, you can also use CDaoRecordset objects without deriving a class of your own. The framework uses record field exchange (DFX for DAO, RFX for ODBC) to exchange data between the database and your recordset's field data members. If you're using a record view, dialog data exchange (DDX) exchanges data between the recordset and the controls on the record view.
Or create an explicit or object in your code for each database you want to open. Base your recordset objects on the database objects. The database object provides an interface to the data source.
In DAO, access a "workspace." Use a object to:
  • Access DAO's default workspace.

  • Manage a separate transaction space.

  • Access the Microsoft Jet database engine.
The workspace lets you manage one or more open databases in a single transaction space.
In DAO, work with tables and perform data definition language (DDL) tasks. Use a object to:
  • Create a recordset.

  • Add a table.

  • Attach to an external data source, such as ODBC.

  • Examine table structure.

  • Add or delete fields and indexes and set other table properties.
In DAO, work with stored queries. Use a object to:
  • Create a recordset.

  • Store a query.

  • Execute an action query or an SQL pass-through query.
Bind data columns to your recordset dynamically. In DAO, use a object directly to set or get field and parameter values. See the article DAO Recordset: Binding Records Dynamically. In ODBC, add code to your derived recordset class to manage the binding. See the article Recordset: Dynamically Binding Data Columns (ODBC).
Work with data in external data sources, such as ODBC data sources (for which you need an ODBC driver, under either ODBC or DAO). A non-external data source is one you can open directly with the Microsoft Jet database engine. In most cases with DAO, use objects to attach tables from the external data source rather than opening the data source directly.

If you have Visual C++ , you can also debug SQL stored procedures and triggers, view data graphically, design and execute queries, and design database schemas.

What do you want to know more about?