Compile Error with ADODB.Connection Object pararmeters

Hello Experts,

I'm attempting to load data from Excel on the client to SQL Server in the clouds.  I'm getting a "Compile Error Syntax error" on the line where 'rs_sql.Open' is executed. (see code).  The empty tables have been created on SQL Server and correspond with the columns in Excel.

Thank you for your help.

Dim conn_excel As New ADODB.Connection
Dim conn_sql As New ADODB.Connection
Dim rs_excel As New ADODB.Recordset
Dim rs_sql As New ADODB.Recordset

Sub loadSQLServer()

conn_sql.Open ("Provider=sqloledb; Data;Initial Catalog=intCat;Uid=userID; Password=pw;")
conn_excel.Open ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database\XLHybrid.xlsm; Extended Properties=Excel 12.0;")

rs_sql.Open("SELECT * FROM SalesOrders WHERE 0=1", conn_sql, adOpenDynamic, adLockOptimistic")
rs_excel.Open("SalesOrders$", conn_excel, adOpenStatic, adLockReadOnly, adCmdTable")

Do While Not rs_excel.EOF
  For i As Integer = 0 To rs_excel.Fields.Count - 1
    rs_sql.Fields(rs_excel.Fields(i).Name).Value = rs_excel.Fields(i).Value


    MsgBox "Error, no records returned.", vbCritical
End If

'Error checking
Set cnn = Nothing
Set rsData = Nothing

Exit Sub

MsgBox Err.Description, vbCritical

If CBool(cnn.State And adStateOpen) Then

Set cnn = Nothing
Set rsData = Nothing


End If

End Sub

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Máté FarkasDatabase Developer and AdministratorCommented:

rs_sql.Open("SELECT * FROM SalesOrders WHERE 0=1", conn_sql, adOpenDynamic, adLockOptimistic)

Open in new window

Hi there,

Not only that line but at least the next line as well has an extra "

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hi there,

If you amenable, I am open to splitting the points since agux3e did in fact solve the immediate issue on the line reported.
brohjoeAuthor Commented:
Ok, that sounds fair.
brohjoeAuthor Commented:
I've got another open question that hasnt been answered concerning the same code.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.