Hi all, i encounter an syntax error "Syntax Error in Insert Into" when i try to run this code... anyone can assist? Thanks!

Dim sConnectionString As String
sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=H:\Users\Desktop\EmployeeAway2.xlsx;Extended Properties=""Excel 12.0;HDR=YES;"""
Dim objConn As New System.Data.OleDb.OleDbConnection(sConnectionString)
objConn.Open()
Dim objCmd As New System.Data.OleDb.OleDbCommand()
objCmd.Connection = objConn
objCmd.CommandText = "Insert into [Sheet1$] (EmployeeID, DateFiled, Name, Department, Reason, From, To, NumberofDays, LeaveApplied, ApprovedBy)" & _
" Values ('John', 'John', 'John', 'John', 'John', 'John', 'John', 'John', 'John', 'Thomas')"
objCmd.ExecuteNonQuery()
objConn.Close()

I think it may be because FROM and TO are reserved words. You need to delimit them as you have Sheet1$. Or rename your columns because that'll catch you out time and again...

This question has already been answered. Start a new discussion instead.