乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      備份還原 sql server 進度條

       獨孤求財 2012-03-20

      備份還原 sql server 進度條

      時間:2011-5-26來源:yang 作者: peng點擊: 44次

      備份SQL Server數(shù)據庫時使用進度條

      作者: penal
      email: mysqlcced@163.com

      使用SQL語句在代碼中備份還原SQL Server數(shù)據庫,如果數(shù)據庫比較大,界面只能阻塞,等待備份還原完成。這段時間無法顯示一些進度信息,讓界面看起來更加友好。下面介紹一種方法,可以在備份還原的同時,顯示進度條。

      const
        ConnStr = ‘Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security In‘ +
                  ‘fo=False;Initial Catalog=master‘;

      function GetProgress: Integer;
      var
        Msg: WideString;
        S: string;
        Err: IErrorInfo;
        I: Integer;
      begin
        // 取得OLE DB的錯誤或警告要通過GetErrorInfo, 即使消息不屬于錯誤也必須通過
        // 這種方式來獲取.
        if (GetErrorInfo(0, Err) = S_OK) and (Err <> nil) then
        begin
          if Err.GetDescription(Msg) = S_OK then
          begin
            S := ‘‘;
            // 取得百分比的字值
            for I := 1 to 3 do
            begin
              if Char(Msg[I]) in [‘0‘..‘9‘] then
                S := S + Msg[I]
              else
                Break;
            end;
            if TryStrToInt(S, Result) then Exit;
          end;
        end;
        Result := -1;
      end;

      procedure TForm1.BtnBackupClick(Sender: TObject);
      const
        BackupSQL = ‘BACKUP DATABASE [pubs] TO  DISK = N%s WITH NOINIT, NOUNLOAD, ‘ +
                  ‘NAME = N%s, NOSKIP, STATS = 10, NOFORMAT‘;
        BakFile = ‘D:\pubs.bak‘;
        BakName = ‘pubs 備份‘;
      var
        SQL: string;
        Conn: _Connection;
        Rst: _Recordset;
        RecsAffected: OleVariant;
        percent: Integer;
      begin
        PBar.Position := 0;
        Conn := CoConnection.Create;
        Conn.Open(ConnStr, ‘‘, ‘‘, 0);
        SQL := Format(BackupSQL, [QuotedStr(BakFile), QuotedStr(BakName)]);
        Rst := Conn.Execute(SQL, RecsAffected, adCmdText);
        while Rst <> nil do
        begin
          percent := GetProgress;
          if percent <> -1 then
            PBar.Position := percent;
          Application.ProcessMessages;
          Rst := Rst.NextRecordset(RecsAffected);
        end;
      end;

        本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多