title: Error on Connection close when connecting VBA to Oracle
body: <p>I'm encountering an error when connecting to an Oracle DB from VBA code in an Excel Spreadsheet. The query that I run works fine, but when I try to close the connection, I get the following error: </p>
  
  <p>Runtime Error 3265: Item cannot be found in the collection corresponding to the requested name or ordinal.</p>
  
  <p>A copy of my code is below. The error occurs on the line "cn.close". Any help would be greatly appreciated!</p>
  
  <pre><code>Sub GetData()
  Dim cn As New ADODB.Connection 
  comm As New ADODB.Command
  rs As New ADODB.Recordset
  On Error GoTo errhandler:
  
      cn.ConnectionString = "DSN=XXX;Uid=XXX;Password=XXX;"    
      cn.Open
  
      comm.CommandType = adCmdText
      comm.CommandText = "Select * from XXX where rownum &lt; 10;"
      Set comm.ActiveConnection = cn
      rs.ActiveConnection = cn
      rs.Open comm
      Sheets("Sheet1").Range("a1").Offset(1, 0).CopyFromRecordset rs  'copy the records
      rs.Close
  
      cn.Close
  
  errhandler:
      Debug.Print (Err.Description)
      Debug.Print "Error# " &amp; cn.Errors(0).NativeError &amp; ": " &amp; cn.Errors(0).Description
  Stop
  
  End Sub
  </code></pre>