DAO: Writing a Database Application

HomeOverviewHow Do IFAQSampleTutorialODBC Driver List

This family of articles discusses writing database applications with the MFC DAO classes. Other articles focus on various parts of the process; this article looks at using DAO from an application design standpoint.

In This Article

This article considers:

Other Articles in the Article Family on the Process

The following additional articles discuss parts of the design and development process (in recommended reading order):

What Is a Database Application?

Database applications obtain and manipulate data from a database managed by a database management system (DBMS). Typical database applications include programs for data input, data viewing, and batch processing of data.

Of course, there is no one kind of database application. There is a wide range from simple data entry or data viewing applications to complex client/server applications.

Beyond that, applications of any sort might use a database rather than disk-based files for input/output. For example, an e-mail client program that you use to read your mail doesn’t feel like a traditional database application, but it might use a database to store addresses, messages, and other information. In any case, the MFC DAO classes supply abstractions that you can use to write any kind of database application.

First Steps in Writing Your MFC DAO Application

To begin, you must make two fundamental decisions:

Your decisions determine how your application fits into MFC's document/view architecture and how appropriate the DAO classes are for your application. Your answers also help determine the selections you make when you run AppWizard to begin constructing your application.

Data Viewing Choices

MFC supplies varying degrees of support for different viewing choices:

Documents and Views with DAO

Do you need the MFC document/view architecture? The simplest architecture for MFC applications is to manage your data within an MFC document object and manage displaying that data separately in a view object. You aren't limited to this structure, though. Other options include:

For related information, see the articles MFC: Using Database Classes with Documents and Views and MFC: Using Database Classes Without Documents and Views.

DBMS Choices

DAO is based on the Microsoft Jet database engine. Thus, DAO is optimally suited for working with Microsoft Jet (.MDB) databases. DAO also supports accessing external databases, including certain installable ISAM databases (which the database engine can read directly) and ODBC data sources. This means you can write DBMS-independent applications with DAO, targeting any data source that the Microsoft Jet database engine can read directly or for which your users will have the appropriate ODBC driver.

Note, however, that in general it is more efficient, with DAO, to attach ODBC data source tables to a Microsoft Jet database than it is to access the external data source directly. If your application is targeted on an external data source such as Microsoft SQL Server or Oracle, you might want to consider using the MFC ODBC classes instead of DAO.

For related information, see the articles Database Topics (DAO) and DAO External: Working with External Data Sources.

See Also   DAO: Where Is..., DAO: Database Tasks, DAO: Database Application Design Options, DAO: Steps in Writing MFC DAO Applications, MFC: Using Database Classes with Documents and Views, MFC: Using Database Classes Without Documents and Views.