CDaoDatabase::Close
Call this member function to disconnect from a database and close any open recordsets, tabledefs, and querydefs associated with the database.
virtual void Close( );
Remarks
It is good practice to close these objects yourself before you call this member function. Closing a CDaoDatabase object removes it from the Databases collection in the associated workspace. Because Close does not destroy the CDaoDatabase object, you can reuse the object by opening the same database or a different database.
Warning
Call the Update member function (if there are pending edits) and the Close member function on all open recordset objects before you close a database. If you exit a function that declares CDaoRecordset or CDaoDatabase objects on the stack, the database is closed, any unsaved changes are lost, all pending transactions are rolled back, and any pending edits to your data are lost.
Warning
If you try to close a database object while any recordset objects are open, or if you try to close a workspace object while any database objects belonging to that specific workspace are open, those recordset objects will be closed and any pending updates or edits will be rolled back. If you try to close a workspace object while any database objects belonging to it are open, the operation closes all database objects belonging to that specific workspace object, which may result in unclosed recordset objects being closed. If you do not close your database object, MFC reports an assertion failure in debug builds.
If the database object is defined outside the scope of a function, and you exit the function without closing it, the database object will remain open until explicitly closed or the module in which it is defined is out of scope.
Requirements
Header: afxdao.h