恢复数据库时出现问题 [英] Problem in restoring a database
问题描述
朋友们,
我正在使用SQL 2005服务器数据库。我在vb.net 10中开发了一个应用程序。我正在备份。它工作得很好。 bt在恢复时给出了错误。
我的代码是:
Dim query As String
试试
query =从磁盘恢复数据库员工='H:\Stuff \Backup \ backup1.bak'
Dim con As SqlConnection = New SqlConnection(Data Source = .\SQLEXPRESS; Initial Catalog = Trial1; Integrated Security = True; Pooling = False)
con.Open()
Dim cmd As SqlCommand = New SqlCommand (查询,骗局)
cmd.ExecuteNonQuery()
MsgBox(Okk)
Catch ex As Exception
MsgBox(ex.ToString)
结束尝试
这是什么错误?请帮帮我。
hi friends,
i'm using SQL 2005 server database. I hv developed an application in a vb.net 10. i am taking backup. and it is working ver fine. bt while restoring it is giving error.
My code is :
Dim query As String
Try
query = "Restore Database Employee From Disk='H:\Stuff\Backup\backup1.bak' "
Dim con As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=Trial1;Integrated Security=True;Pooling=False")
con.Open()
Dim cmd As SqlCommand = New SqlCommand(query, con)
cmd.ExecuteNonQuery()
MsgBox("Okk")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
What is the mistake? please help me out.
推荐答案
错误信息非常明确:您的数据库正在使用中。执行还原时,必须关闭与数据库的所有连接。不只是您当前的应用程序 - 但是所有PC上的每个访问数据库的应用程序都必须关闭。
The error message is pretty explicit: your database is in use. You have to close all connections to the DB while you do the restore. Not just your current app - but every application that is accessing the database has to be shut down, on all PCs.
这篇关于恢复数据库时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!