title: Getting "[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'Microsoft.'
body: <p>I'm getting an error, "[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'Microsoft.'</p>
  
  <p>Here is the code:</p>
  
  <pre><code>Dim conn As ADODB.Connection
  Dim rst As ADODB.Recordset
  Dim stSQL As String
  
  
  
  
  Public Sub loadData()
   'This was set up using Microsoft  ActiveX Data Components version 6.0.
  
  
  
   'Create ADODB connection object, open connection and 
   '       construct the connection string object which is the DSN name.
   Set conn = New ADODB.Connection
   conn.ConnectionString = "sql_server"
  
  conn.Open
  'conn.Execute (strSQL)
  
  On Error GoTo ErrorHandler
  
  'Open Excel and run query to export data to SQL Server.
  strSQL = "SELECT * INTO SalesOrders " &amp; _
           "FROM OPENDATASOURCE(Microsoft.ACE.OLEDB.12.0;" &amp; _
           "Data Source=C:\Workbook.xlsx;" &amp; _
           "Extended Properties=Excel 12.0; [Sales Orders])"
  
  conn.Execute (strSQL)
  
  'Error handling.
  ErrorExit:
   'Reclaim memory from the cntection objects
   Set rst = Nothing
   Set conn = Nothing
  
  Exit Sub
  
  ErrorHandler:
     MsgBox Err.Description, vbCritical
     Resume ErrorExit
  
  
  'clean up and reclaim memory resources.
  conn.Close
  If CBool(cnt.State And adStateOpen) Then
  Set rst = Nothing
  Set conn = Nothing
  
  End If
  
  End Sub
  </code></pre>