DAO: Closing DAO Objects

HomeOverviewHow Do IFAQSampleTutorialODBC Driver List

All MFC DAO objects have Close member functions. Calling Close typically closes any subordinate objects, such as the active recordsets in a database object, before closing the parent object. The following illustrates closing a database object:

// pdbAccounts is an open CDaoDatabase object
pdbAccounts->Close( );

Note   It is considered good practice to explicitly close your objects rather than relying on containing objects to close them.

Meaning of the Close Action for Different DAO Objects

The concept of “close” is similar for MFC DAO objects. Closing an object:

What Happens When You Close Objects

For details about what happens when you close an MFC DAO object, see the Close member function for that object's class:

 Calling Close does not destroy the MFC object; you must do that separately.

Tip   It is considered good programming practice to explicitly close your objects before they go out of scope.

See Also   CDaoWorkspace::Open, CDaoWorkspace::Close, CDaoDatabase::Open, CDaoDatabase::Close, CDaoTableDef::Open, CDaoTableDef::Close, CDaoQueryDef::Open, CDaoQueryDef::Close, CDaoRecordset::Open, CDaoRecordset::Close, CDaoDatabase::Create, CDaoQueryDef::Create, CDaoTableDef::Create, CDaoWorkspace::Create