title: Does setting an ADO Command's ActiveConnection = Nothing close the underlying SQL Connection?
body: <p>I have a customer who's Classic ASP application is generating ASP_0147 errors. The first thing I'm checking is that they're closing and releasing SQL/ADO resources timeously.</p>
  
  <p>Their code has the following pattern:</p>
  
  <pre><code>Function GetXXXXRecordSet()
    Set objConn = Server.CreateObject("ADODB.Connection")
    With objConn 
      .CursorLocation = 3 ''adUseServer (default)
      .ConnectionString = strConnectionString
      .Open
    End With
  
    Set objCmd = Server.CreateObject("ADODB.Command")
    Set objCmd.ActiveConnection = objConn
  
    '' Build command object to call SQL stored proc, snipped for brevity
  
    Set objRs = Server.CreateObject("ADODB.RecordSet")
    objRs.Open objCmd, ,3,4 '' Cursor=adOpenStatic, Locktype=adLockBatchOptimistic
  
    '' Return Recordset
    Set GetXXXXRecordSet = objRs
  
    If Not objCmd Is Nothing Then
      objCmd.ActiveConnection = Nothing  '' Should this use a Set statement?
      Set objCmd = Nothing
    End If
    If Not ObjRs Is Nothing The Set objRs = Nothing
  End Function
  </code></pre>
  
  <p>Does setting an ADO Command's ActiveConnection = Nothing close the underlying SQL Connection or does that have to be closed explicitly?</p>
  
  <p>Also should the line:</p>
  
  <pre><code>objCmd.ActiveConnection = Nothing
  </code></pre>
  
  <p>be:</p>
  
  <pre><code>Set objCmd.ActiveConnection = Nothing
  </code></pre>
  
  <p>Oddly the first version doesn't generate an error which is why I ask.</p>
  
  <p>It's been so long since I looked at ADO and my knowledge is somewhat rusty.</p>