|
发表于 2020-4-28 19:15:01
|
显示全部楼层
我刚好写好,送你了,可以运行的,语言:delphi
备份:
var
path:string; //存放备份路径的变量
begin
path:=trim(ExtractFilePath(Application.ExeName))+'数据库备份\'+'db2.mdb';
try
if path <>'' then
begin
copyfile(pchar('db1.mdb'),pchar(path),true);
application.MessageBox(pchar('备份成功!'+#13),'XGY',mb_ok+mb_iconinformation);
end;
except
begin
application.MessageBox(pchar('备份失败!'+#13),'XGY',mb_ok+mb_iconwarning);
abort;
end;
还原:
var
dbname, dbbname: string;
begin
if MessageBox(self.Handle, '确认要还原数据么? ', '提示', mb_IconQuestion + mb_YesNo) = idYes then
begin
dbname := ExtractFilePath(Application.ExeName)+ '数据库备份\'+'db2.mdb';
dbbname := ExtractFilePath(Application.ExeName)+'新建文件夹\'+ 'db1.mdb';
if not FileExists(dbname) then
MessageBox(self.Handle, '没有备份数据,不能还原', '提示', mb_IconInformation + mb_Ok)
else
begin
CopyFile(Pchar(dbname), Pchar(dbbname), true);
MessageBox(handle, '数据库还原成功!', '提示', mb_IconInformation + mb_Ok);
end;
end;
end;
|
|