here's some sample code for doing it with access 97; it will
probably work with 2000 as well.
note that you can't compact "in place" -- you have to
specify a destination file. if you want to compact in place,
you have to move the file first, then compact it back to its
original path, then delete the original.
CString c1, c2;
c1.Format("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine
Type=4;Data Source=%s", src_path);
c2.Format("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine
Type=4;Data Source=%s", dst_path);
_bstr_t c1_bstr(c1);
_bstr_t c2_bstr(c2);
try {
IJetEnginePtr jet;
jet.CreateInstance(__uuidof(JetEngine));
jet->CompactDatabase(c1_bstr, c2_bstr);
Quote:}
catch (...) {
return FALSE;
Quote:}
hope that helps,
r
> did you ever get an answer to this question. i'm trying to do the same thing
> (w/an Access 97 db)
> thanks,
> -j
> >How do I compact an Access 2000 DB in Visual C++ using ADO? I'm using the
> >import "msado15.dll" call.
> >Thanks in advance,
> >--
> >John M. Drescher
> >Systems Analyst / Programmer III
> >University of Pittsburgh Radiology Department
> >http://www.geocities.com/SiliconValley/Haven/1654/