注册 登录
编程论坛 Delphi论坛

Delphi和sql系统备份

发布于 2010-04-30 10:44, 590 次点击
怎么才能实现系统的备份?
1 回复
#2
2010-04-30 15:14
procedure TForm1.Button1Click(Sender: TObject);
var
  Path:string;
begin
  form1.SaveDialog1.Filter:='所有文件(*.*)|*.*';
  form1.SaveDialog1.Title:='选择备份路径和文件名';
  if form1.SaveDialog1.Execute=true then
    begin
      Path:=form1.SaveDialog1.FileName;
    end;
  if Path<>'' then
    begin
      with form2.ADOQuery1 do
        begin
          try
            screen.Cursor:=crHourGlass;
            close;
            sql.Clear;
            sql.Add('backup database fisbase to disk='+''''+Path+'''');
            execsql;
            screen.Cursor:=crDefault;
            application.MessageBox('数据库备份成功完成','数据库备份',0+mb_iconinformation);
          except
            screen.Cursor:=crDefault;
            application.MessageBox('数据库备份失败!请检查备份路径或网络状态','数据库备份',0+mb_iconinformation);
            exit;
          end;
        end;
    end;
end;
1