The IJetCompact interface exposes maintenance operations on the OLE DB Provider for Microsoft Jet. Compact is the only supported method on this interface. It does both database compaction and repair.
This interface is defined under the DataSource cotype in Appendix D of the OLE DB Programmer's Reference, "Cotypes, Structures, and Enumerated Types."
IJetCompact is implemented only in version 4.0 and later.
Method | Description |
---|---|
IJetCompact | Compacts/repairs a database, creating a new copy |
Compacts or repairs a database, creating a new database. The old database is retained unchanged.
HRESULT IJetCompact::Compact( ULONG cPropertySets, DBPROPSET rgPropertySets[]);
Compact is called to copy a database and remove extraneous space. The original database is left unchanged. This routine also will repair corruption in the database if possible. This routine will work only for Red ISAM databases—other IISAMs are not supported. This routine will not work if the database is already opened with permissions to write to the database.
Before calling Compact, the user should ensure that adequate space exists for the newly created database and that the data source object has been initialized.
The initialization properties from the data source object are used as the source for this method. Furthermore, the current values of these properties are used as a template for this routine—the caller needs to set only those properties that are important to distinguish the new database. Usually this means that only DBPROP_INIT_DATASOURCE needs to be passed to this routine to specify the new name for the compacted database. Unneeded properties are ignored by this method.
Several OLE DB Provider for Microsoft Jet–specific properties affect how this method operates:
These properties are ignored on all other methods that take data source object properties. Therefore, you can either specify these on the data source object or pass values to this method. Values passed to this method override any previously set values.
Additionally, a database can be compacted to be encrypted or nonencrypted. This is controlled by the DBPROP_JETOLEDB_ENCRYPTDATABASE (Boolean) property.
By default, Compact will create a new database of the same version as the original database. If you want to compact to a newer file format, specify the DBPROP_JETOLEDB_ENGINETYPE (enumeration) property. Values for this property are defined in Msjetoledb.h. You cannot compact databases to a previous Jet format.