Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
DarkConsultant
Starting Member
17 Posts |
Posted - 2009-01-04 : 06:47:19
|
| Hi Everyone,Using SQL Server 2005 and VB.Net 2005I am trying to use SQLDMO dll to back up and restore a database. The backup side seems to work OK as I can back up to a device or file. When I try to restore then I hit a problem.The code..Dim MySQLServer As New SQLDMO.SQLServerDim MyRestore As New SQLDMO.RestoreWith MyRestore .Files = "C:\SQLBackup\Contacts.bkp" .Database = "Contacts" .ReplaceDatabase = True MySQLServer.LoginSecure = True MySQLServer.Connect(MyLocal.SQLServer, _ADMINLOGIN, _ADMINPASS) .SQLRestore(MySQLServer) (ERROR HERE)End WithThe error I am geting is -[Microsoft][ODBC SQL Server Driver][SQL Server]Exclusive access could not be obtained because the database is in use.[Microsoft][ODBC SQL Server Driver][SQL Server]RESTORE DATABASE is terminating abnormally.The database I am trying to restore is on another PC on my LAN and I have checked and there is only one user in the database at the time of the error and that is me. I have to log in to run the command but then it appears by logging in I am stopping it from working.I have searched the Net and found loads of references to the error and they all say 'There must still be a user logged in, log the user out and try again.' This does not help me as I am the user!I am sure there is a simple answer to this but I cannot find it anywhere. Your help would be most appreciated.Many thanks in anticipation |
|
|
|
|
|