title: Incorrect Syntax Near GO in ADODB Connection for Excel
body: <p>I'm trying to pull data from a SQLServer database with a stored proc directly into and excel spreadsheet. I'm trying to make a dashboard that will allow the user to make a selection for the specific month they want to see and pull the data for that month. Once the data is pulled, the dashboard will automatically calculate which charts the user will see and so forth.  This is my first time pulling from an ADODB connection, though, and I'm getting a problem  trying to actually pull the data. I get the error "Incorrect Syntax Near 'GO'" on the line where I'm trying to copy from the recordset. Any help would be greatly appreciated.</p>
  
  <p>EDIT: This is the new code. I'm now getting the run-time error 3704: Cannot perform this operation when the object is closed. It's still happening when I try to copy from the recordset.</p>
  
  <pre><code>Sub btnPullData_Click()
  Dim objConn As New ADODB.Connection
  Dim objRecordset As ADODB.Recordset
  Dim rngTableCell As Range
  Dim drpPicker As DropDown
  Dim strDropVal As String
  Dim objCommand As New ADODB.Command
  
  
  Set rngTableCell = Range("celFirstInTable")
  rngTableCell.ListObject.DataBodyRange.Rows.Delete
  
  Set drpPicker = ThisWorkbook.Sheets("Dashboard").DropDowns("dropFis_Month")
  strDropVal = Format(drpPicker.List(drpPicker.ListIndex), "mmm-yy")
  
  objConn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=KPITRACKER;Data Source=JEFFSQL"
  
  With objCommand
      .CommandType = adCmdStoredProc
      .CommandText = "DynamicPhonesSP"
      .Parameters.Append .CreateParameter("@TimeSum", advarWChar, , 1, "m")
      .Parameters.Append .CreateParameter("@TimeSum1", advarWChar, , 1, "d")
      .Parameters.Append .CreateParameter("@TimeParam", advarWChar, , 20, strDropVal)
      .Parameters.Append .CreateParameter("@RptLevel", adInteger, , , 1)
      .ActiveConnection = objConn
      Set objRecordset = .Execute
  End With
  
  ThisWorkbook.Sheets("Data").Range("B6").CopyFromRecordset objRecordset
  
  objRecordset.Close
  Set objRecordset = Nothing
  objConn.Close
  Set objConn = Nothing
  
  End Sub
  </code></pre>