G
goodbobi
Unregistered / Unconfirmed
GUEST, unregistred user!
按照這個貼子<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=3330303<br><br>问题:分享:实现带进度条的数据库备份!(SQL Server) ( 积分:0, 回复:46, 阅读:1356 )<br>分类:数据库-C/S型 ( 版主:qince, luyear ) <br>来自:yitang, 时间:2006-1-16 13:48:00, ID:3330303 <br><br>請問有誰寫出了恢複的程序呀.我改了一下.同一台電腦恢複可以,拿到另一台恢複就不行了,報錯:<br>[SQL-DMO]您必須指定備份或還原的備份裝置<br>代碼如下:<br>procedure TFM_Main.SpeedButton2Click(Sender: TObject);<br>var<br> MySQLServer: SQLServer;<br> MyRestore: Restore2;<br> FInterfaceConnection: integer;<br> BS:TRestoreSink;<br>begin<br> if EdtResPath.Text = '' then begin<br> Forms.Application.MessageBox('請選擇您的恢複路徑!', '提示', MB_OK+MB_ICONINFORMATION);<br> EdtResPath.SetFocus;<br> Exit;<br> end;<br> if EdtResServerName.Text = '' then begin<br> Forms.Application.MessageBox('請輸入你的服務器名稱!', '提示', MB_OK+MB_ICONINFORMATION);<br> EdtResServerName.SetFocus;<br> Exit;<br> end;<br> if EdtResDatabaseName.Text = '' then begin<br> Forms.Application.MessageBox('請輸入你的資料庫名稱!', '提示', MB_OK+MB_ICONINFORMATION);<br> EdtResDatabaseName.SetFocus;<br> Exit;<br> end;<br> if Forms.Application.MessageBox(PChar('您確認要恢復資料庫'+EdtResDatabaseName.Text+'嗎?'#13#13'此操作會將數據恢復到備份時的狀態, 請慎重處理!'),'確認', MB_YESNO+MB_ICONQUESTION) = IDNO then<br> exit;<br> try<br> Forms.Application.ProcessMessages;<br> BS:=TRestoreSink.Create;<br> MySQLServer := coSQLServer.Create;<br> MyRestore := coRestore2.Create;<br> MySQLServer.Connect(EdtResServerName.Text, ConUserName, ConPassword); //連接信息<br> MyRestore.Database := EdtResDatabaseName.Text; //資料庫名稱<br> MyRestore.Files := GetShortName(ExtractFilePath(EdtBakPath.Text)) + ExtractFileName(EdtBakPath.Text); //恢複路徑<br> // MyRestore.Initialize := true;<br> MyRestore.PercentCompleteNotification := 1;<br> MyRestore.Action := 0; //0完整備份,1差異備份,2文件組備份,3日誌備份<br> InterfaceConnect(MyRestore, IID_RestoreSink, BS, FInterfaceConnection); //關鍵是這裏<br> MyRestore.SQLRestore(MySQLServer);<br> InterfaceDisconnect(MyRestore, IID_RestoreSink, FInterfaceConnection);<br> Forms.Application.MessageBox('資料庫恢複成功!', '成功', MB_OK+MB_ICONINFORMATION);<br> ProgressBar1.Position := 0;<br> except<br> on e: exception do<br> Forms.Application.MessageBox(PChar('資料庫恢複失敗!'#13#13+e.Message), '失敗', MB_OK+MB_ICONERROR);<br> end;<br>end;