System.Data.SqlClient.sqlError: Exclusive access could not be obtained because the database is in use (Microsoft.SqlServer.Smo)
Lets see what you need to do to solve this problem...
Reason for this error is most of the time database will be used by a program. You just have to kill that so database will be free to restore.
Reason for this error is most of the time database will be used by a program. You just have to kill that so database will be free to restore.
Right click on the Database after login in to the Microsoft SQL Server Management Studio with right previlages. Select Rasks and go to Detach. In general page you will see the database you have right clicked with a Message saying how many active connections are. Click on the message will pop up a new window with the Process info.
Right click on the process and kill Process will free the database to restore.