Close Method

See Also      Applies To

Closes an open DAO object.

Syntax

VOIDClose(VOID);

Remarks

Closing an open object removes it from the collection to which it's appended. Any attempt to close the default workspace is ignored.

If the CdbConnection, CdbDatabase, CdbRecordset, or CdbWorkspace object is already closed when you use Close, a run-time error occurs.

Caution If you exit a procedure that declares CdbConnection, CdbDatabase, or CdbRecordset objects, those objects are closed, all pending transactions are rolled back, and any pending edits to your data are lost.

If you try to close a CdbConnection or CdbDatabase object while it has any open CdbRecordset objects, the CdbRecordset objects will be closed and any pending updates or edits will be canceled.  Similarly, if you try to close a CdbWorkspace object while it has any open CdbConnection or CdbDatabase objects, those CdbConnection and CdbDatabase objects will be closed, which will close their CdbRecordset objects.

Using the Close method on either an original or cloned CdbRecordset object doesn't affect the other CdbRecordset object.

To remove objects from updatable collections other than the Connections, Databases, Recordsets, and Workspaces collections, use the Delete method on those collections. You can't add a new member to the Containers, Documents, and Errors collections.

Usage

#include <afxole.h>
#include <dbdao.h>

CdbDatabase   db;
db = dben.OpenDatabase(_T("MyDatabase.mbd"));
...               // Do some work.
db.Close();        // Close the database.