Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

restore database

Status
Not open for further replies.

3615

Programmer
Jun 22, 2001
22
FR
I need to Backup and restore a database from a VB application.

First to backup a database using BACKUP DATABASE etc... in a stored procedure called from VB, there is no problem.

But when I use a command RESTORE DATABASE FROM etc...
Error Message: "System admin exclusivity needeed..." or something Like this(Sorry for my english...)

How can i do ?

thanks
 
I would suspect that there are users connected to the database when you are trying to restore.... try putting a sp_who in before the restore to see. if there are people in the db, then you will have to either kill them or have them change the database context.

I have a stored proc that will kill all users if that is the problem. Paul
 
Thanks for your answer Paul.

For my tests i'm the only user of the database.

I tried to execute a "RESTORE DATABASE etc..." with a new connection on a MASTER database (from my VB program) to be sure that there is no connection on MY database, and that is OK.

But i can't do that if my VB program have been connected 2 times. I set all active ADODB.connections to nothing before to restore MY database, but it seems that one connection is still active and i can't find it.

This is a VB Problem now ?




 
Are you logging in to the database you want to restore? Issue a "USE master" command prior to the restore command so the context of your connection is master rather than the database being restored. Terry

"I'm not dumb. I just have a command of thoroughly useless information." - Calvin, of Calvin and Hobbes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top