我試圖恢復遠程SQL服務器上的一個.bak文件,但我發現試圖恢復遠程數據庫
Cannot open backup device .bak Operating system error 21(The device is not ready.). RESTORE DATABASE is terminating abnormally.
這就是我想
var restore = new Restore();
restore.Database = databaseName;
restore.Action = RestoreActionType.Database;
restore.Devices.AddDevice(backUpFilePath, DeviceType.File);
restore.ReplaceDatabase = true;
restore.NoRecovery = false;
var sqlConnection = new SqlConnection(ConnectionString);
var serverConnection = new ServerConnection(sqlConnection);
var sqlServer = new Server(serverConnection);
restore.SqlRestore(sqlServer);
標記您正在使用的dbms。 (爲了得到更好的關注,這是一個特定於產品的問題,甚至與SQL語言無關。) – jarlh
錯誤消息似乎是說它認爲「.bak」是備份設備。這就是我首先要看的。 ('restore.Devices.AddDevice(...)') –