I had the same problem and my solution was:
Make sure you don't open the database you are restoring. Use any other DB.
Your modified code should look similar to this...
: set conn = server.CreateObject("ADODB.connection")
: conn.Open "Provider=SQLOLEDB.1;Driver={SQL
: Server};Server=servername;Database=master;UID=User;PWD=password"
:
: SQL = "Restore Database MyTest from Disk='c:\mytest.bk' with
: Recovery"
:
: Set RS=Conn.execute(SQL)
Regards Lasse
> You are probably right. I'm a little bit in the dark on this one. Can
you
> suggest any modifications to my script?
>
> Thanks,
> Eli
>
> -----Original Message-----
> From: Ken Schaefer [mailto:ken@a...]
> Sent: Wednesday, December 12, 2001 7:18 PM
> To: ASP Database Setup
> Subject: [asp_database_setup] Re: SQL Restore script
>
>
> Don't you either need to kill all the other processes using the DB (use
EM
> to see these), or start the server in admin mode (with the -m switch) to
do
> a restore? (I could be wrong abotu this...)
>
> Cheers
> Ken
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> From: "Eli Schilling" <eschilli@t...>
> Subject: [asp_database_setup] SQL Restore script
>
>
> : I'm currently trying to setup a page that does an automatic SQL restore
> : using a file that gets dumped onto the SQL server every night.
Currently
> I
> : have:
> :
> : set conn = server.CreateObject("ADODB.connection")
> : conn.Open "Provider=SQLOLEDB.1;Driver={SQL
> : Server};Server=servername;Database=MyTest;UID=User;PWD=password"
> :
> : SQL = "Restore Database MyTest from Disk='c:\mytest.bk' with
> : Recovery"
> :
> : Set RS=Conn.execute(SQL)
> :
> : Conn.close
> :
> : When I execute this script I get:
> :
> : Error Type:
> : Microsoft OLE DB Provider for SQL Server (0x80040E14)
> : Database in use. The system administrator must have exclusive use of
the
> : database to run the restore operation.
> : /sqlrestore.asp, line 11
> :
> : However, I have nothing open in the DB and no one is connected to it.
If
> I
> : run this same script in query analyzer it executes but then the
database
> : shows as "Loading" until I do a manual restore through Enterprise
Manager.
> :
> : Is there a better script for restoring or am I doing something wrong
here?
>
>
eschilli@t...
> $subst('Email.Unsub')
>
> $subst('Email.Unsub').