DMO - Disconnecting Connections

  • When I need to restore or detach a database I keep getting the following error :

    Project ******* raised exception class EOleException with message '[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot detach the database 'LetITTables' because it is currently in use'. Process stopped. Use Step or Run to continue.

    How can I enumerate all connections to the database in question through DMO and kick them out so that I can detach the database?

    DAN

  • The server object has an enumprocesses method that returns a queryresult. Probably easier to just query sysprocesses directly via ADO then issue kill for anything still connected.

    Andy

  • quote:


    The server object has an enumprocesses method that returns a queryresult. Probably easier to just query sysprocesses directly via ADO then issue kill for anything still connected.

    Andy


    Andy, thanks for the prompt reply. How do I issue the kill command for connections?

  • Just use executeimmediate and pass the spid.

    Andy

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply