1

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Smashery
  • 57,848
  • 30
  • 97
  • 128
  • 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 Answers1

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