服务器“\\.\pipe\81DAC374-2583-49\tsql\query”恢复失败
错误:*“服务器 '\.\pipe\81DAC374-2583-49\tsql\query' 恢复失败。”*
我在此处收到错误 resDB .SqlRestore(sv)
我的备份工作正常,但恢复失败。过去两天我试图让它工作,但还没有成功。
Public Shared Sub RestoreBackup()
Dim sConnect As String = My.Settings.LICConnectionString
Dim dbName As String
Using cnn As New SqlConnection(sConnect)
cnn.Open()
dbName = cnn.Database.ToString()
cnn.ChangeDatabase("master")
Dim sc As New ServerConnection(cnn)
Dim sv As New Server(sc)
' Check that I'm connected to the user instance
MsgBox(sv.InstanceName.ToString())
' Create backup device item for the backup
Dim bdi As New BackupDeviceItem("C:\Backup\LIC.bak", DeviceType.File)
' Create the restore object
Dim resDB As New Restore()
resDB.Devices.Add(bdi)
resDB.NoRecovery = False
resDB.ReplaceDatabase = True
resDB.Database = dbName
' Restore the database
resDB.SqlRestore(sv)
MsgBox("Your database has been restored.")
End Using
End Sub
为什么会失败?感谢任何帮助。
Error : *"Restore failed for Server '\.\pipe\81DAC374-2583-49\tsql\query'."*
i get the error here resDB.SqlRestore(sv)
My backup works fine but restore fails.i am trying to get it working from the past two days and no luck yet.
Public Shared Sub RestoreBackup()
Dim sConnect As String = My.Settings.LICConnectionString
Dim dbName As String
Using cnn As New SqlConnection(sConnect)
cnn.Open()
dbName = cnn.Database.ToString()
cnn.ChangeDatabase("master")
Dim sc As New ServerConnection(cnn)
Dim sv As New Server(sc)
' Check that I'm connected to the user instance
MsgBox(sv.InstanceName.ToString())
' Create backup device item for the backup
Dim bdi As New BackupDeviceItem("C:\Backup\LIC.bak", DeviceType.File)
' Create the restore object
Dim resDB As New Restore()
resDB.Devices.Add(bdi)
resDB.NoRecovery = False
resDB.ReplaceDatabase = True
resDB.Database = dbName
' Restore the database
resDB.SqlRestore(sv)
MsgBox("Your database has been restored.")
End Using
End Sub
Why does it fail??Any Help Appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎正在尝试通过主数据库进行恢复。您需要将
cnn.ChangeDatabase("master")
更改为cnn.ChangeDatabase("LIC")。
编辑:
或者,删除行
cnn.ChangeDatabase("master")
一起,并在实例化 Restore 类后添加以下行:此外,如果备份来自另一台服务器,您可能需要使用
RelocateFile
查看代码> - 如何从 C# 恢复数据库It looks like you're trying to restore over the master database. You will need to change
cnn.ChangeDatabase("master")
tocnn.ChangeDatabase("LIC").
EDIT:
Alternatively, remove the line
cnn.ChangeDatabase("master")
altogether and add the following line after instantiating the Restore class:Also, if the backup is from another server you may want to look at using
RelocateFile
- How to restore a database from C#