Click here to Skip to main content
15,397,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I used this code to restor database but it cannot do restor opration?

VB
OpenFileDialog1.FileName = database
                        OpenFileDialog1.ShowDialog()
                        Filename = OpenFileDialog1.FileName
                        strQuery = "ALTER DATABASE [c:\Didar\didar.mdf] SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
                        strQuery = "RESTORE DATABASE [c:\Didar\didar.mdf] FROM DISK=N'" & Filename & "' WITH NOFORMAT, NOINIT, NAME = 'x', SKIP, NOREWIND, NOUNLOAD, STATS = 10"

                        strQuery = "ALTER DATABASE [c:\Didar\didar.mdf] SET MULTI_USER"
                        Dim cmd As SqlCommand
                        cmd = New SqlCommand(strQuery, con)
                        cmd.ExecuteNonQuery()
Posted
Comments
Prasad_Kulkarni 4-May-12 3:24am
   
Glad it helps!
Thank you for 'Accepting Solution'

1 solution

   
v3
Comments
Maciej Los 4-May-12 4:31am
   
Good links. My 5!
Prasad_Kulkarni 4-May-12 4:32am
   
Thank you losmac!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900