procedure TDBBackupForm.XP_Button2Click(Sender: TObject);
begin
With SaveDialog1 do
begin
filename:='DB'+FormatDateTime('yy_MM_dd_hh_mm_ss',Now);
options:=[ofhidereadonly,offilemustexist,ofpathmustexist];
if execute then
begin
{close connection}
DataModule1.ADOConnection1.Close;
{copy file}
FillChar(fo, SizeOf(fo), 0);
with fo do
begin
Wnd := 0;
wFunc := FO_COPY ;
pFrom := PChar(InitDB+#0);
pTo := pchar(FileName+#0);
fFlags := FOF_NOCONFIRMATION+FOF_SILENT;
end;
if (SHFileOperation(fo) <> 0) then
begin
ShowMessage('数据库文件复制失败,请重试,或与管理员联系!');
exit;
end;
ShowMessage('数据库已经成功备份到 '+filename+'!');
Try
DataModule1.ADOConnection1.Connected:= True;
Except
ShowMessage('无法重新接连数据库!,系统即将退出!');
Application.Terminate;
End;
self.Close;
end;
end;
end;