title: Cannot drop database because it is currently in use
body: <p>I want to drop a database. I have used the following code, but to no avail.</p>
  
  <pre><code>public void DropDataBase(string DBName,SqlConnection scon)
  {
      try
      {
          SqlConnection.ClearAllPools();
          SqlCommand cmd = new SqlCommand("ALTER DATABASE " + DBName + "     SET SINGLE_USER     WITH ROLLBACK IMMEDIATE", scon);
          cmd.CommandType = CommandType.Text;
          scon.Open();
          cmd.ExecuteNonQuery();
          scon.Close();
  
          SqlCommand cmddrpdb = new SqlCommand("drop database " + DBName + "", scon);
          cmddrpdb.CommandType = CommandType.Text;
          scon.Open();
          cmddrpdb.ExecuteNonQuery();
          scon.Close();
      }
      catch (Exception ex)
      {
          MessageBox.Show("DropDataBase : " +ex.Message);
      }
  }
  </code></pre>
  
  <p>I am getting Error as <strong>cannot drop database because it is currently in use</strong>.
  Please help me out in the above mentioned issue.</p>