Hello,
I am using SQL Server 2008 and i am trying to restore a database from Vb 2010 with this the code below but had this erro
"RESTORE cannot process database 'DatabaseName' because it is in use by this session. It is recommended that the master database be used when performing this operation.
RESTORE DATABASE is terminating abnormally"
I am using SQL Server 2008 and i am trying to restore a database from Vb 2010 with this the code below but had this erro
"RESTORE cannot process database 'DatabaseName' because it is in use by this session. It is recommended that the master database be used when performing this operation.
RESTORE DATABASE is terminating abnormally"
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
con = New SqlConnection(DataBaseConnectionString)
cmd = New SqlCommand("restore database StudentManagement_DB from disk='j:\filename.bak'", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Sub