DB Reload

greenspun.com : LUSENET : SQL Server Database Administration : One Thread

I am trying to write some ASP code that will restore my backup database a dump of the database. when searching yahoo, i came across your resume, can u help?

this is the error i continually get from my code....

---------------------

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Database in use. The system administrator must have exclusive use of the database to run the restore operation.

/rebuild.asp, line 8

---------------------

this is my asp code

< %
set MyConn=Server.CreateObject("ADODB.Connection")
set instruct=server.createobject("adodb.command")

myConn.Open "DSN=mydsn;uid=myuser;pwd=mypassword"
MyConn.execute("RESTORE DATABASE MYDB FROM DISK = 'BEAUTY_D.DAT'")
MyConn.close
Response.Write("Done!")
% >

because i am doing this throu a very unhelpful hosting company, i cannot figure out why its not working. There is nobody else using the datbase, and I tried reloading this a thousand times, always the same error..... Can u help?????

\THanks!!!

John

-- Anonymous, July 25, 2001

Answers

John,

You have to make sure that the database doesn't have any connections before restoring it.

Use sp_who to find out what other connections your database has. Then, if you cannot terminate the extra processes yourself, persuade the SQL Server system administrator to use the KILL command to kill the other connections to the database.

Hope this helps,

Eric

-- Anonymous, July 26, 2001


Moderation questions? read the FAQ