Board index » delphi » Compress an Access 97 Database

Compress an Access 97 Database

How can I compress an Access 97 Database from Delphi 4.0?
In Visual Basic there was a command, so it must be possible,
but I havent found anything similar in Delphi.

Any Help?. Thank you.

Antonio

 

Re:Compress an Access 97 Database


Hello ~

I have done that using Delphi v4 /w MS-ACCESS 97.
Since I was using ADO components from ADOnis and they have some JRO
components for doing this, I could easily implented it.
I am currently using Adonis ADO components v4.

hope that this helps you a lot !

Quote
"Antonio Revuelta" <revue...@www.agbar.es> wrote in message

news:8ljc1h$d0k4@bornews.borland.com...
Quote
> How can I compress an Access 97 Database from Delphi 4.0?
> In Visual Basic there was a command, so it must be possible,
> but I havent found anything similar in Delphi.

> Any Help?. Thank you.

> Antonio

Re:Compress an Access 97 Database


Quote
>How can I compress an Access 97 Database from Delphi 4.0?
>In Visual Basic there was a command, so it must be possible,
>but I havent found anything similar in Delphi.

You can not do this via the BDE Access driver.  You can do it with ole
automation using DAO or ADO

Try this code for DAO
function TMainForm.PackAccessDB(strDBPathName:String): boolean;
var varDBEngine: variant;
    strTempPathName: string;
begin
  result := true;
  try
    strTempPathName := ExtractFilePath(strDBPathName);
    strTempPathName := strTempPathName + 'temp.mdb';
    varDBEngine := CreateOleObject('DAO.DBEngine');
                              // DAO.dbEngine.35 for DAO 3.5
    try
      varDBEngine.CompactDatabase(strDBPathName, strTempPathName);
      DeleteFile(strDBPathName);
      RenameFile(strTempPathName, strDBPathName);
    except
      result := false;
    end;
  finally
    varDBEngine := Unassigned;
  end;
end;
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads