上面有SpeedButton,SaveDialog,OpenDialog,RadioButton控件
procedure Tsjbfyhy.SpeedButton1Click(Sender: TObject);
var
path:string;
begin
if RadioButton1.Checked then
if SaveDialog1.Execute then
if SaveDialog1.FileName <> '' then
begin
path:=ExtractFilePath(application.ExeName);
try
copyfile(pchar(' d:/data/test.mdb'), pchar(SaveDialog1.FileName+'.mdb'), false);
messagebox(getactivewindow(),'成功备份数据!','提示!' ,MB_OK + MB_ICONINFORMATION);
except
messagebox(getactivewindow(),'备份数据失败,请重试!!','错误!' ,MB_OK + MB_ICONERROR);
end;
end;
end;
procedure Tsjbfyhy.SpeedButton2Click(Sender: TObject);
var
path:string;
begin
if RadioButton2.Checked then
if OpenDialog1.Execute then
if OpenDialog1.FileName <> '' then
begin
path := ExtractFilePath(application.ExeName);
try
form1.ADOConnection1.Connected := false;
Deletefile('d:/data/test.mdb');
copyfile(pchar(OpenDialog1.FileName),pchar('d:/data/test.mdb'), false);
messagebox(getactivewindow(),'成功恢复数据,单击确定后请重新运行软件!','提示!' ,MB_OK + MB_ICONINFORMATION);
Application.Terminate;
except
messagebox(getactivewindow(),'恢复数据失败,请重试!!','错误!' ,MB_OK + MB_ICONERROR);
end;
end;
end;
可能有的地方没有改过来,这是我自己做的数据备份与还原!