Database Options in AppWizard

HomeOverviewDetailsSample

This topic describes the MFC database options available in Step 2 of the MFC AppWizard. These options include:

A record view — derived from class CRecordView (for ODBC) or class CDaoRecordView (for DAO)— is a form view, based on a dialog template resource, that uses dialog data exchange (DDX) to exchange data between the view’s controls and a CRecordset-derived object (for ODBC) or a CDaoRecordset-derived object (for DAO). You can map the form’s controls to data members of a recordset. For more information about record views, see the article Record Views. For more information about recordsets, see the article Recordset (ODBC) or the article DAO Recordset.

No Database Support

AppWizard defaults to this option (“None” in the AppWizard dialog box) and adds no database support to your application.

Only Include Header Files

Choose this option for the minimum database support. AppWizard adds an #include directive for the header file that defines the database classes. The file AFXDB.H (for ODBC) and the file AFXDAO.H (for DAO) are included in STDAFX.H.

Note that if you do choose a database view with AppWizard, you will only be given the single #include that corresponds to your choice of ODBC or DAO. Your application probably won’t need access to both. When you don’t choose a database view, however, AppWizard can’t anticipate which you prefer, so it provides both.

With this support, you can use any of the database classes, related macros and global functions, and other items defined in the appropriate include file. AppWizard creates no database-related classes for you except for a view class and a recordset class if you choose one of the Database View options; you can create what you need later with ClassWizard.

AppWizard no longer explicitly adds libraries to the link line. The libraries are automatically included by special #pragma directives scattered throughout the MFC header files. You don’t need to worry about library names.

A Database View, Without File Support

Choose this option when you want an application with the following characteristics:

Note   Choosing this option makes the application single document interface (SDI). Choosing file support allows either SDI or MDI (multiple document interface).

This option creates a CDocument-derived class. In general, you’ll use this class to store a CRecordset object, or a pointer to one. For more information on how to use this document class, see the article MFC: Using Database Classes Without Documents and Views. The article discusses various document/view configurations, including applications with no document or view.

Both a Database View and File Support

Choose this option when you want an application with the following characteristics:

Note   For the last two options, AppWizard binds all columns of the table(s) you select to the recordset. If you don’t want all the columns, you can remove some of them later with ClassWizard. See the article ClassWizard: Binding Recordset Fields to Table Columns.

What do you want to know more about?