Social Icons

Pages

Backup Restore Database Accsess (Mdb)

program sederhana yang penting dalam membuat aplikasi yaitu mengamankan data jika keadaan aplikasi error dan mungkin juga database terhapus, berikut ini adalah source Backup dan Restore database Access pada pemprogramman Delphi :

Backup Data:
procedure TBackup.Button1Click (Sender: TObject);
var
path: string;
begin
if SaveDialog1.Execute then
if SaveDialog1.FileName <>'' then
begin
path: = ExtractFilePath (application.ExeName);
try
copyfile (pchar (path + 'db.mdb'), pchar (SaveDialog1.FileName + '. bak'), false);
ShowMessage ('backup was successful!');
except
ShowMessage ('backup failed, please retry!');
end;
end;
end;

Restore Data  :
Procedure TBackup.Button2Click (Sender: TObject); 
var
path: string;
begin
if OpenDialog1.Execute then
if OpenDialog1.FileName <>'' then
begin
path: = ExtractFilePath (application.ExeName);
try
TBackup.ADOConnection1.Connected: = false;
DeleteFile (path + the 'db.mdb');
copyfile (pchar (OpenDialog1.FileName), pchar (path + 'db.mdb'), false);
ShowMessage ('successful recovery of data!');
Application.Terminate;
except
ShowMessage ('recovery failed, please try again!');
end;
end;
end;

0 comments:

Post a Comment

 
Blogger Templates