Board index » delphi » HELP - compress and repair Access db in Delphi not working?

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


2005-02-25 09:41:54 AM
delphi201
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;
 
 

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

"jason" <XXXX@XXXXX.COM>writes
Quote

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');
Hi Jason,
If you did not get an answer to this; try removing the "Persist Security
Info=false" from the strings. I believe this fails as it it is not defined
in the interface for JRO.
Jim