HOWTO: Compacting Microsoft Access Database via ADOID: Q230501
|
Although ADO specification does not provide objects to compact or repair Microsoft Access databases, this capability can be achieved by using the ADO extension: Microsoft Jet OLE DB Provider and Replication Objects (JRO). This capability was implemented for the first time in the JET OLE DB Provider version 4.0 (Msjetoledb40.dll) and JRO version 2.1 (Msjro.dll). These DLL files are available after the install of MDAC 2.1. You can download the latest version of MDAC from the following Web site:
Universal Data Access Web Site
To repair and compact an Access database using ADO, MDAC 2.1 or later must be properly installed on the computer. The following are the main steps to compact a Microsoft Access database using Visual Basic and Visual C++:
Dim jro As jro.JetEngine
Set jro = New jro.JetEngine
jro.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\nwind2.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\abbc2.mdb;Jet OLEDB:Engine Type=4"
#import "C:\PROGRAM FILES\COMMON FILES\System\ado\MSJRO.DLL" no_namespace
...
try
{
IJetEnginePtr jet(__uuidof(JetEngine));
jet->CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\nwind2.mdb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\abbc.mdb;Jet OLEDB:Engine Type=4");
}
catch(_com_error &e)
{
::MessageBox(NULL, (LPCTSTR)e.Description( ), "", MB_OK) ;
}
Jet OLEDB:Engine Type | Jet x.x Format MDB Files |
---|---|
1 | JET10 |
2 | JET11 |
3 | JET2X |
4 | JET3X |
5 | JET4X |
Additional query words: CompactDatabase RepairDatabase reindex
Keywords : kbADO210 kbDatabase kbJET kbProvider kbVBp600 kbVC kbGrpVCDB kbGrpMDAC
Version : WINDOWS:2.1,4.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 21, 1999