m_adil
asked on
Access DB...
How can I compact and repair an access DB?
ASKER
do i need to include something in uses clause ? its giving me error.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes it worked. thanks alot.
also can u help me in this problem as well ?
https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20242809
Thanks
also can u help me in this problem as well ?
https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20242809
Thanks
here's a function to do that using the ADO technology
Function CompactAndRepair(sOldMDB : String; sNewMDB : String) : Boolean;
const
sProvider = 'Provider=Microsoft.Jet.OL
var
oJetEng : JetEngine;
begin
sOldMDB := sProvider + 'Data Source=' + sOldMDB;
sNewMDB := sProvider + 'Data Source=' + sNewMDB;
try
oJetEng := CoJetEngine.Create;
oJetEng.CompactDatabase(sO
oJetEng := Nil;
Result := True;
except
oJetEng := Nil;
Result := False;
end;
end;
Example :
if CompactAndRepair('e:\Old.m
ShowMessage('Successfully'
else
ShowMessage('Error?');
if you would like to use DAO for old database like Access
97
uses ComObj;
procedure TForm1.Button1Click(Sender
var
dao: OLEVariant;
begin
dao := CreateOleObject('DAO.DBEng
dao.CompactDatabase('C:\My
'C:\My Documents\CompactedDB1.mdb
end;
for more info look at this question
https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20162957
Best regards
Mohammed Nasman