2012年3月19日星期一

Disconnect from sql server database

Hi
I have c# application that uses SQL SERVER databases.
The problem is that after I close all connections to a database in order to
make actions (detach, copy or delete) on the current database I get a
message saying that the database still has connections.
At the Enterprise manager I can see that the current database still has 2
connections although I closed them in my application.
I would like to disconnect from the database through the application and
make the actions that were mentioned above, how can I do that?
Thanks,
Eyal
On SQL SERVER 2000, you can disconnect all the current connections with:
ALTER DATABASE your_database SET SINGLE_USER WITH ROLLBACK IMMEDIATE
USE master
DROP DATABASE your_database etc..
You need USE master, otherwise you're still connected yourself.
Jacco Schalkwijk
SQL Server MVP
"Eyal" <eg@.margan.com> wrote in message
news:eYltEA3BFHA.3592@.TK2MSFTNGP09.phx.gbl...
> Hi
>
> I have c# application that uses SQL SERVER databases.
> The problem is that after I close all connections to a database in order
> to
> make actions (detach, copy or delete) on the current database I get a
> message saying that the database still has connections.
>
> At the Enterprise manager I can see that the current database still has 2
> connections although I closed them in my application.
>
> I would like to disconnect from the database through the application and
> make the actions that were mentioned above, how can I do that?
>
> Thanks,
> Eyal
>

没有评论:

发表评论