Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 Restoring Database

$
0
0
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"


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


Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>