title: How do you completely close an SQLConnection string in vb.net?
body: <p>I'm running a multithreaded application that connects to a database, the connections are closed when I'm done with them (and I dispose of all the threads).  I've tried clearing the connection pools, setting pooling=false and I've used both .dispose and .close.</p>
  
  <p>I get the error "cannot drop the database X because it is currently in use" if I try to drop the database I connected to after the connections have all been closed.  Below is my code:</p>
  
  <pre><code>Dim comExecuteInsert As New SqlCommand
  Dim comm As New SqlConnection
  If (Not comm Is Nothing) Then
      comm = Nothing
  End If
  comExecuteInsert.Connection = comm
  comExecuteInsert.CommandType = CommandType.StoredProcedure
  comExecuteInsert.CommandText = strProcedureName
  comExecuteInsert.CommandTimeout = 26000
  comExecuteInsert.Parameters.Add("@tableName", SqlDbType.VarChar, 100).Value = strTableName
  comExecuteInsert.Parameters.Add("@filename", SqlDbType.VarChar, 500).Value = strFileName
  comExecuteInsert.ExecuteScalar()
  comExecuteInsert.Parameters.Clear()
  
  comExecuteInsert = Nothing
  comm.Close()
  SqlConnection.ClearPool(comm)
  </code></pre>
  
  <p>The stored procedure creates temporary tables which it later drops and inserts data into tables existing in the database.</p>