Dropping SQL Server database through C#

后端 未结 7 1887
误落风尘
误落风尘 2020-12-29 07:24

I am using this code to delete a database through C#

Int32 result = 0;

try
{
        String Connectionstring = CCMMUtility.CreateConnectionString(false, txt         


        
相关标签:
7条回答
  • 2020-12-29 08:17

    In this case i would recommend that you take the database offline first... that will close all connections and etc... heres an article on how to do it: http://blog.sqlauthority.com/2010/04/24/sql-server-t-sql-script-to-take-database-offline-take-database-online/

    Microsoft clearly states that A database can be dropped regardless of its state: offline, read-only, suspect, and so on. on this MSDN article (DROP DATABASE (Transact-SQL))

    0 讨论(0)
提交回复
热议问题