Share via


DAO Record Field Exchange (DFX)

OverviewHow Do IFAQSampleODBC Driver List

The MFC DAO database classes automate moving data between the data source and a recordset using a mechanism called “DAO record field exchange” (DFX). DFX is similar to dialog data exchange (DDX) and, at the interface level, almost identical to record field exchange (RFX) for the MFC ODBC classes. If you understand RFX, you will find DFX easy to use.

****Note   ****The MFC DAO database classes are distinct from the MFC database classes based on ODBC. All DAO class names have the "CDao" prefix. Where the ODBC classes are based on Open Database Connectivity (ODBC), the DAO classes are based on Data Access Objects (DAO), which use the Microsoft Jet database engine. In general, the MFC DAO classes have more capabilities than the MFC ODBC classes. For more information, see the article DAO and MFC.

The DoFieldExchange Mechanism for DAO

Moving data between a data source and the field data members of a recordset requires multiple calls to the recordset’s function and considerable interaction between the framework and DAO. The DFX mechanism is type-safe and saves you the work of allocating storage and binding data to it. Sometimes, however, there will be a performance penalty for this ease of use. (For more information about DDX, see Dialog Data Exchange and Validation.)

Derived Recordset Classes for DAO

DFX is mostly transparent to you. If you declare your recordset classes with AppWizard, ClassWizard, WizardBar, or ClassView, DFX is built into them automatically. DAO recordset classes are normally derived from the base class supplied by the framework (but see Using CDaoRecordset Directly Instead of Deriving). AppWizard lets you create an initial recordset class. ClassWizard, WizardBar, and ClassView let you add other recordset classes as you need them. You use the wizards to map recordset field data members to table columns on the data source. For more information and examples, see the article ClassWizard: Creating a Recordset Class.

You must manually add a small amount of DFX code in two cases — when you want to:

  • Use parameterized queries. See the article DAO Queries: Filtering and Parameterizing Queries.

  • Perform joins — using one recordset for columns from two or more tables, joined on a common field by a WHERE clause in the SQL statement such as:

    WHERE Course.CourseID = Section.CourseID
    

Using CDaoRecordset Directly Instead of Deriving

There is an alternative to using DFX (and derived classes). You can use CDaoRecordset directly (without deriving from it) to bind a specified field in the current record dynamically. For more information, see the article DAO Recordset: Binding Records Dynamically.

More Information About DFX

If you need a more advanced understanding of DFX, see the article DAO Record Field Exchange: How DFX Works.

The following articles explain the details of using recordset objects:

See Also   DAO: Where Is..., DAO Recordset, ClassWizard: Creating a Recordset Class, Overview: Creating a Program That Supports a Database,