How can I call Access's Compact and Repair Database utility from within C++? I'm already using ADO and ADOX, so a solution using either of those would be handy.
Asked
Active
Viewed 2,610 times
1
-
Just to clarify, compact and repair are not independent operations. Since Jet 3.5 SR2 (c. 1998), there is no separate repair command, only a compact. Compact checks the integrity of any MDB it's run on and if it needs to be repaired does so. MS removed the separate repair command because running it on an undamaged MDB was sometimes corrupting them. – David-W-Fenton Apr 27 '09 at 20:04
-
Another example of how an MDB can go corrupt :) – onedaywhen Apr 28 '09 at 08:44
1 Answers
2
Similiar to:
How can I programmatically repair (not merely compact) an Access .mdb file?
You can do this using COM
to access the JRO.JetEngine
object. There is an example in C# at CodeProject which shouldn't be too hard to convert to C++.
UPDATE: Thanks to @le dorfier, here is an article with C++ example.

Community
- 1
- 1

Mitch Wheat
- 295,962
- 43
- 465
- 541
-
Yes, I saw that one there - however, I am asking about a C++ solution, which neither that question, nor any of the answers seemed to address. – Smashery Apr 27 '09 at 04:33
-
1Here's the same thing for C++ http://support.microsoft.com/kb/230501 found with googling "c++ JRO.JetEngine" – dkretz Apr 27 '09 at 05:12
-
-
Any ideas on how to compact and repair an Access 2007 .accdb database file by code? – TheAgent Oct 10 '09 at 15:32