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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot kill own connection!!! pls help!

Status
Not open for further replies.

Fori

Programmer
Jun 18, 2003
84
MT
Hi All

so i've built a vb program which connects with a SQL Server (MSDE) 2000. I have a function to backup which works perfectly but the restore function doesn't!

The error givin said that i had users connected..fair enough! i then used the kill to kill all the spid which are concerned with the databased used! worked!! but when it comes to the current connection (using ado) it says that it cannot kill own connection! I understand it .....

but have no idea how i can kill process in a simple way!! pls any help and code could be very useful!

Thanks
Nick


 
To restore, put the database in SINGLE-USER mode. That allows one and only one connection. Then that connection HAS to be the one doing the restore.

-SQLBill
 
Should have added:

ALTER DATABASE databasename SINGLE_USER WITH ROLLBACK IMMEDIATE

That puts the database in single usere mode after rolling back any transactions and immediately 'KILL'ing any connections (except the one issuing the command).

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top