Share via


Should I Use DAO or ODBC?

OverviewHow Do IFAQ   |  ODBC Driver List

Which set of MFC classes should you use? This depends on your needs:

  • Use the ODBC classes if you are working strictly with ODBC data sources, particularly in client/server situations, where the MFC ODBC classes provide better performance.

  • Use the DAO classes if you are working primarily with Microsoft Jet (.MDB) databases or with other database formats that the Microsoft Jet database engine can read directly. For a list of these, see What Databases Can I Access with DAO and ODBC?

  • Access ODBC data sources via the DAO classes when you want the speed of the Microsoft Jet database engine and the extra functionality of the DAO classes.

****Note   ****DAO requires additional hard disk space.

The DAO classes have the following advantages:

  • Better performance in some cases, particularly when using Microsoft Jet (.MDB) databases.

  • Compatibility with the ODBC classes and with Microsoft Access Basic and Microsoft Visual Basic.

  • Access to validation rules.

  • Ability to specify relations between tables.

  • A richer data access model, with support for Data Definition Language (DDL) as well as Data Manipulation Language (DML). For details, see Database Definition and Manipulation.

Here’s a summary of the key differences to help you choose:

Choosing Between MFC’s DAO and ODBC Classes

Can I... with DAO Classes? with ODBC Classes?
Access .MDB files Yes Yes
Access ODBC data sources Yes Yes
Available for 16 Bit No Yes
Available for 32 Bit Yes Yes
Database compaction Yes No
Database engine support Microsoft Jet database engine Target DBMS
DDL support Yes Only via direct ODBC calls
DML support Yes Yes
Nature of the MFC implementation “Wrapper” of DAO core functions Simplified abstraction rather than a “wrapper” of the ODBC API
Optimal for .MDB files (Microsoft Access) Any DBMS for which you have a driver, especially in client/server situations
Transaction support Per “workspace” or, for ODBC data, per database Per database

Keep in mind that the capabilities of ODBC drivers vary. See the ODBC Programmer’s Reference and the help file for your ODBC driver for more information. For information about using ODBC via DAO, see the article DAO External: Working with External Data Sources.