Share via


DAO: Steps in Writing MFC DAO Applications

OverviewHow Do IFAQSampleODBC Driver List

This article continues the discussion begun in the articles DAO: Writing a Database Application and DAO: Database Application Design Options. Those articles describe application design choices. This article explains the steps you take to develop your application.

Once you've made your initial design decisions, follow these steps:

  1. Run AppWizard to create a skeleton application.

    On the databases page, select the database options you want. It is at this stage that you specify a if you want a form-based application.

    When you open the Database Options dialog box, select DAO rather than ODBC. The result is an application with the right include directives and libraries for using the DAO classes. The wizard prompts you to specify the name of a Microsoft Jet (.MDB) database.

  2. If needed, add a object for each database your application can open simultaneously.

    If these objects need to persist for long periods, declare them as data members of one of your classes that point to CDaoDatabase objects you create on the heap — the document is a good choice.

    If they are to persist for long, create the objects with the new operator, perhaps in your document's member function or in a command-handler function for a menu command.

  3. Use your CDaoDatabase object(s) to create objects that represent queries.

    If you prefer to create your recordsets on the fly, you can omit the object(s). MFC will implicitly create a CDaoDatabase object if you don't supply a pointer to one in the recordset's call.

    You can create your recordsets on the heap, or you can create them as local variables in a function.

See Also   DAO: Where Is..., DAO Recordset, Record Views, DAO: Database Tasks, DAO: Database Application Design Options, MFC: Using Database Classes with Documents and Views, MFC: Using Database Classes Without Documents and Views