My Application is connected to MS Access database. I want to provide one
option as Backup and another option for Restore. I use Delphi 5 with ADO to
connect DB.
What is the best way to Backup the Dabase and Restore it?
I think as this is a Filebased DB, We should Make a Copy of the Database
file (.mdb) and Compact the new copied file.
Please suggest any idea. If i can get some Code fragment it will be helpful
for me.
Thanks
Prabhat
http://prabhatnath.blogspot.com
procedure TdmData.CompactAndRepairDatabase(AInput, AOutput: string;
BackUp: Boolean = False);
const
sConString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=';
var
oJetEng: JetEngine;
begin
adocData.Close;
if FileExists(AOutput) then
DeleteFile(PChar(AOutput));
oJetEng:= CoJetEngine.Create;
try
try
oJetEng.CompactDatabase(sConString + AInput, sConString + AOutput);
if not BackUp then
begin
DeleteFile(PChar(AInput));
RenameFile(AOutput, AInput);
end;
except
on E:Exception do
ShowMessage(E.Message);
end;
finally
oJetEng := nil;
end;
adocData.Open;
end;
Hope it helps.
Stu
Thanks for the sample code. Can you please let me know what are the units
that i need to include in "uses" section? I think JRO_TLB will do the work.
Also in your case what is "adocData"? Is that the Connection?
Thanks Again
Prabhat Nath
http://prabhatnath.blogspot.com
"Stuart Bloom" <stu...@thebloomfamily.co.uk> wrote in message
news:4654...@newsgroups.borland.com...
You need to include JRO_TLB (as you correctly found ount). adocData is
TADOConnection.
Hope this helps.
Thanks for the info. Yes it is very useful for me. Thanks.
Prabhat
http://prabhatnath.blogspot.com
You may also like to look at http://cc.codegear.com/Item/15256. BTW, please
don't top post.