尝试还原远程数据库

时间:2017-04-12 10:39:26

标签: c# sql database restore

我正在尝试在远程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);

1 个答案:

答案 0 :(得分:-1)

我认为错误信息非常模糊,因为它可能意味着许多不同的事情。

您是否能够在SQL Server中的应用程序之外恢复.bak? SQL错误日志是否提供了更具体的信息?