Cannot drop database because it is currently in use

后端 未结 17 1483
北恋
北恋 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:32

    For SQL server mgmt. studio:

    Right click database: Properties -> Options -> Restrict Access : Set to "Single User" and perform the drop afterwards

提交回复
热议问题