我想覈實一下我在C#中使用剛剛完成的備份針對SQL Server命令快速如何從Sql Server系統消息獲取返回值?
string _commandText = string.Format("RESTORE VERIFYONLY FROM DISK = '{0}'", backupLocation);
SqlDataReader _sqlDataReader = SqlHelper.ExecuteReader("BookssortedSQLDbConnection", CommandType.Text, _commandText);
如果我在SSMS執行命令返回「備份文件上1有效設置。」但是我怎樣才能把這個消息回傳到我的代碼中呢?
閱讀器不會工作,因爲沒有行被返回。
注意:我已嘗試SMO.Restore對象來嘗試並驗證它,但它不起作用,這就是爲什麼我這樣做。
_restore.SqlVerify(srv, out _errorMessage); //returns false even though bakcup is fine
BTW - 開放的建議,因爲我不認爲這是實現什麼,我試圖做