Using Microsoft Visual C++ and DAO 3.5

Data Access Objects (DAO), the programmatic interface to Microsoft Jet, were originally designed for use with Microsoft Visual Basic and Microsoft Access Basic. With the advent of OLE Automation, it is now possible to write C++ code that uses DAO.

As of Microsoft Jet 3.0, the DAO DLL is an OLE Automation in-process server containing an embedded type library. With the type library, client programs can query the server for descriptions of exposed objects via the OLE IDispatch interface. This process can be tedious, however, so DAO C++ coding has now been simplified by the development of three types of DAO C++ coding:

Which DAO C++ Classes to Use?

If you are familiar with OLE COM programming, then the DAO interfaces may be all you need. Even so, programming with these interfaces requires the declaration of many temporary variables in order to work down the DAO hierarchy to the object you want to work with. This creates many lines of code in itself and each of these objects must be explicitly released by the programmer, which requires additional tracking.

For the additional overhead of a 190K DLL, the dbDAO classes enable you to write more concise code, with no need to keep track of object lifetimes. Conveniences like the classes that handle variants (often the required type used by DAO properties and methods) make programming much easier. Rather than filling out the VARIANT structure, you can simply cast the variable to the appropriate class.

The MFC DAO classes are fully integrated with the MFC wizards and the general MFC object structure. If you are already familiar with MFC, or if you're writing simple database applications that you'd like to easily integrate into your existing MFC-based code, then this is the way for you. If you're more experienced with programming DAO from Visual Basic, then getting started with the dbDAO classes will require less time.