D
delphihouse
Unregistered / Unconfirmed
GUEST, unregistred user!
有进度条的恢复(对原数据库进行恢复)我从网上抄来是这样的<br> MyRestoreSink := TRestoreSink.Create;<br> MySQLServer := coSQLServer.Create;<br> MyRestore := CoRestore2.Create;<br> MySQLServer.Connect(GetServerName, GetdbUserID, GetdbPassWord);<br> MyRestore.Database := DataBaseName;<br> MyRestore.PercentCompleteNotification := 1;<br> MyRestore.Files := RestoreFile;<br> MyRestore.ReplaceDataBase := True;<br> InterfaceConnect(MyRestore, IID_RestoreSink, MyRestoreSink, FInterfaceConnection);//关键是这里<br>... <br><br> try<br> try<br> MyRestore.SQLRestore(MySQLServer);<br> except<br> on e: Exception do<br> begin<br> ErrorMsg := e.Message;<br> Result := False;<br> end;<br> end;<br> finally<br> MySQLServer.Disconnect;<br> end;<br>... <br>而执行数据恢复后,生成新数据库的Trans SQL 是这样的<br><br> q.SQL.Text := Format(' RESTORE FILELISTONLY FROM DISK = ''%s''', [BackupFile]) +CRLF<br> + Format(' RESTORE DATABASE %s ', [NewdbName]) +CRLF<br> + Format(' FROM DISK = ''%s'' ', [BackupFile])+CRLF<br> + ' WITH RECOVERY, ' +CRLF<br> + Format(' MOVE ''%s_Data'' TO ''%s%s_Data.mdf'', ', [DEF_DB_NAME, DataDir, NewdbName])+CRLF<br> + Format(' MOVE ''%s_Log'' TO ''%s%s_Log.ldf'' ', [DEF_DB_NAME, DataDir, NewdbName]);<br> Result := ExecuteADOQuery(q, ErrorMsg);<br><br>现在的问题是如何将这两者起来, 如何用SQL-DEMO实现带进度条的数据库恢复<br>(相当于用RESTORE的方法来创建数据库的复本),恢复后生成新的数据库