{
here is a function i have made to compact and repair an access database.
exclusive access to the db is required!!
}
uses
comobj;
function compactandrepair(db: string): boolean; {db = path to access database}
var
v: olevariant;
begin
result := true;
try
v := createoleobject(jro.jetengine);
try
v.compactdatabase(provider=microsoft.jet.oledb.4.0;data source=+db,
provider=microsoft.jet.oledb.4.0;data source=+db+x;jet oledb:engine type=5);
deletefile(db);
renamefile(db+x,db);
finally
v := unassigned;
end;
except
result := false;
end;
end;