uses combjvar
  X: OleVariant;
  sourcefiles,tempfiles:string;
begin
  sourcefiles:=extractfilepath(application.exename)+'data\database.mdb';
  tempfiles:=extractfilepath(application.exename)+'data\temp.mdb';
  ADOConnection1.Connected:=false;
  try
    X:= createoleobject('JRO.JetEngine');
    x.CompactDatabase('Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+sourcefiles+'','Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+tempfiles+'');
    if fileExists(sourcefiles) and FileExists(tempfiles) then
    if deleteFile(sourcefiles)then
    RenameFile(tempfiles,sourcefiles);
  except
    x.Release;
  end;
    ADOConnection1.Connected:=true;