title: Error 3709 when connecting thru ADODB.connection to SQL Server 2008 in Excel
body: <p>I'm trying to open a recordset on a SQL Server in Excel using the below code, but get a <code>3709 - The connection cannot be used to perform this operation. It is either closed or invalid in this context.</code> error.  Where am I going wrong?:</p>
  
  <p>EDIT:</p>
  
  <p>It is now working, i'll update the code below:</p>
  
  <pre><code>'Declare variables'
      Set objMyConn = New ADODB.Connection
      Set objMyRecordset = New ADODB.Recordset
      Dim strSQL As String
  
  'Open Connection'
      objMyConn.ConnectionString = "Driver={SQL Server};Server=SERVER\SERVER; Database=we_ci_db; Trusted_Connection=Yes"
      objMyConn.Open
  
  'Set and Excecute SQL Command'
      strSQL = "select * from tblUsers"
  
  'Open Recordset'
      Set objMyRecordset.ActiveConnection = objMyConn
      objMyRecordset.Open strSQL
  
  'Copy Data to Excel'
      ActiveSheet.Range("A1").CopyFromRecordset (objMyRecordset)
  </code></pre>