怎样在程序中实现对ACCESS数据库的备份?(30分)

  • 主题发起人 主题发起人 sutao01
  • 开始时间 开始时间
S

sutao01

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样在程序实现对ACCESS数据库的备份?
 
先断开与ACCESS数据库的联接,然后拷贝文件式的拷贝.MDB文件,再恢复该联接。
 
var
failure :boolean;
begin

if FileExists('databackup/dbmath_backup.mdb')OR FileExists('databackup/courseware_backup.mdb')OR FileExists('databackup/dblog_backup.mdb') then
begin
if application.messagebox('备份文件已存在,是否覆盖?', '数据备份',mb_YesNo+MB_APPLMODAL+MB_ICONQUESTION+MB_DEFBUTTON2)=idyes then
begin
failure:=false;
progressbar1.Position:=0;
progressbar1.Max:=1000;
if not copyfile('data/dbmath.mdb','databackup/dbmath_backup.mdb',false) then
failure:=true;
progressbar1.Position:=progressbar1.Position+450;
if not copyfile('data/dblog.mdb','databackup/dblog_backup.mdb',false) then
failure:=true;
progressbar1.Position:=progressbar1.Position+250;
if not copyfile('data/courseware.mdb','databackup/courseware_backup.mdb',false) then
failure:=true;
progressbar1.Position:=progressbar1.Position+300;
if failure then
begin
application.messagebox('数据备份没有成功!','系统提示',mb_ok+MB_ICONQUESTION);
Button1.Enabled:=true;
Button2.Enabled:=true;
end
else
begin
application.messagebox('数据备份结束!','系统提示',mb_ok+MB_ICONQUESTION);
close;
end;
end;
end
else
begin
failure:=false;
progressbar1.Position:=0;
progressbar1.Max:=1000;
if not copyfile('data/dbmath.mdb','databackup/dbmath_backup.mdb',false) then
failure:=true;
progressbar1.Position:=progressbar1.Position+450;
if not copyfile('data/dblog.mdb','databackup/dblog_backup.mdb',false) then
failure:=true;
progressbar1.Position:=progressbar1.Position+250;
if not copyfile('data/courseware.mdb','databackup/courseware_backup.mdb',false) then
failure:=true;
progressbar1.Position:=progressbar1.Position+300;
if failure then
begin
application.messagebox('数据备份没有成功!','系统提示',mb_ok+MB_ICONQUESTION);
Button1.Enabled:=true;
Button2.Enabled:=true;
end
else
begin
application.messagebox('数据备份结束!','系统提示',mb_ok+MB_ICONQUESTION);
close;
end;
end;
Button1.Enabled:=true;
Button2.Enabled:=true;
 
多人接受答案了。
 
后退
顶部