HELP - compress and repair Access db in Delphi not working?

From: jason (jason_at_noreplies.com)
Date: 02/25/05


Date: 24 Feb 2005 17:41:54 -0800


Hi all,

I have a function that gets passed the location of a MS Access
database (copy of entire function below), it then is supposed to
compress and repair the database. However I keep getting
"EOleException ..class not registered" exception on the line
V.CompactDatabase(.....);

Your help would be greatly appreciated! :)

Function is below..

=========================================
function TfrmMaintenance.CompactAndRepair(DB: string): Boolean; {DB = Path to Access Database}
var
  v: OLEvariant;
begin
  Result := True;
  try
    if FileExists(ExtractFilePath(Application.ExeName) + 'TRegSvr.exe') then
    begin
      ShellExec( Application.Handle, '', ExtractFilePath(Application.ExeName) + 'TRegSvr.exe', '-q C:\Program Files\Common Files\System\ADO\msjro.dll', ExtractFilePath(Application.ExeName), SW_HIDE);
    end;
    v := CreateOLEObject('JRO.JetEngine');
    try
      V.CompactDatabase('Provider=Microsoft.Jet.4.0;Data Source='+DB+';Mode=Share Deny None;Persist Security Info=false;Jet OLEDB:Engine Type=5;Database Password=xxxxxxxx'
                        ,'Provider=Microsoft.Jet.4.0;Data Source='+DB+'x;Mode=Share Deny None;Persist Security Info=false;Jet OLEDB:Engine Type=5;Database Password=xxxxxxxx');

      Result := true;
      // DeleteFile(DB);
      // RenameFile(DB+'x',DB);
    finally
      V := Unassigned;
    end;
  except
    Result := False;
  end;
end;



Relevant Pages

  • Re: KirbyBase
    ... I'm an Object Guy and Jamey is a Database Guy. ... That requires the table name and key field name to be specified ... I suppose it would in effect be embedding an array where all the ... that is) might compress by a factor of 10 or more. ...
    (comp.lang.ruby)
  • Re: MDB will no longer accept reuslts
    ... If the compress occurs whenever *anything* closes the database, ... Microsoft FrontPage MVP ...
    (microsoft.public.frontpage.client)
  • Re: Compressing a .mdw file
    ... >> we copy it and compress it using Tools | Database ... >> We decided to compress it by writing a program and using ... >> then renaming the original to x.old and renaming the new ... >Dim jro As JRO.JetEngine ...
    (microsoft.public.access.security)
  • Re: How do you decompress compressed files on XP-Home Ed.?
    ... but just now I wanted to access one of those files which had database ... files in it (it was Avery labels database files), so when I clicked on one ... How did you compress the file? ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Compressing Files
    ... >From Acc97 you can set an option to compress the database on close. ... Access 2003 offers a file option to backup a database. ...
    (microsoft.public.access.modulesdaovba)