Cannot drop database because it is currently in use

后端 未结 17 1478
北恋
北恋 2020-12-07 11:50

I want to drop a database. I have used the following code, but to no avail.

public void DropDataBase(string DBName,SqlConnection scon)
{
    try
    {
               


        
17条回答
  •  臣服心动
    2020-12-07 12:41

    A brute force workaround could be:

    1. Stop the SQL Server Service.

    2. Delete the corresponding .mdf and .ldf files.

    3. Start the SQL Server Service.

    4. Connect with SSMS and delete the database.

提交回复
热议问题