Compacting Access database programatically

  • Thread starter Thread starter Simon Johnson
  • Start date Start date
S

Simon Johnson

Hi all,

I'm writing a program that does a lot of table droping and updating..
After i've performed these steps it would be nice to run the compact and
repair function on the database. How can I do this?

Yours,

Simon.
 
Simon,

I don't believe that there is a command that you can issue through the
OleDb provider that will do this. You might have luck with ADOX (accessed
through COM interop), but I am not sure if there is a method there to do
that.

At the worst, you can use COM interop to open up an instance of Access
(hidden of course) which opens the MDB file, and then compacts it. The
object model for Access most definitely exposes this functionality.

Hope this helps.
 
Hi,

In addition to what Nicholas has said about compacting
the access database, take a look at the following article.

http://support.microsoft.com/default.aspx?
scid=http://support.microsoft.com:80/support/kb/articles/Q
230/5/01.ASP&NoWebContent=1

As Nicholoas as said, u have to use COM interop to do the
above.

Hope this helps...

Regards,
Madhu

MVP | MCSD.NET
-----Original Message-----
Simon,

I don't believe that there is a command that you can issue through the
OleDb provider that will do this. You might have luck with ADOX (accessed
through COM interop), but I am not sure if there is a method there to do
that.

At the worst, you can use COM interop to open up an instance of Access
(hidden of course) which opens the MDB file, and then compacts it. The
object model for Access most definitely exposes this functionality.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Simon Johnson said:
Hi all,

I'm writing a program that does a lot of table droping and updating..
After i've performed these steps it would be nice to run the compact and
repair function on the database. How can I do this?

Yours,

Simon.


.
 
Back
Top