CdbDBEngine::CompactDatabase Method

Copies and compacts a closed database, and gives you the option of changing its version, collating order, and encryption (Microsoft Jet workspaces only).

Syntax

VOIDCompactDatabase(LPCTSTR pstrOldDatabase,

LPCTSTR pstrNewDatabase,

LPCTSTR pstrDstConnect = NULL,

LONG lOptions=-1,

LPCTSTR pstrSrcConnect = NULL);

Parameters

Type Example Description
LPCTSTR pstrOldDatabase A pointer to a string that identifies an existing, closed database. It can be a full path and file name, such as "C:\db1.mdb". If the file name has an extension, you must specify it. If your network supports it, you can also specify a network path, such as "\\server1\share1\dir1\db1.mdb".
LPCTSTR pstrNewDatabase A pointer to a string that is the file name (and path) of the compacted database that you're creating. You can also specify a network path. You can't use the NewDatabase argument to specify the same database file as OldDatabase.
LPCTSTR pstrDstConnect Optional. A pointer to a string composed of zero or more parameters separated by semicolons. This parameter is used to pass additional information to the destination database as needed. For example, collating order is specified here.
LONG IOptions Optional. A constant or combination of constants that indicates one or more options. The options specify the version of its data format and whether the new compacted database should be encrypted.
LPCTSTR pstrSrcConnect Optional. A pointer to a string composed of zero or more parameters separated by semicolons. This parameter is used to pass additional information from the source as needed.

Remarks

All users must close the database before you compact it. If the database isn't closed or isn't available for exclusive use, an error occurs.

Usage

#include <afxole.h>
#include <dbdao.h>
...
CdbDBEngine   dben;
...
dben.CompactDatabase(   _T("Northwind.mdb"), _T("Nwind2.mdb"),
                     dbLangGeneral, // This is really a string.
                     dbVersion30);