View Full Version : syntax help -- Importing Excel Data into SQL Access Table


ryu
08-04-2009, 12:36 PM
I am trying to import data from Excel to an Access database using SQL functions. I keep getting the "FROM clause syntax error". I matched my output with the requirement on MS website and am pretty sure I have the syntax right but I am still getting error messages. Can someone help? Thanks.

Here is my code.

strSQL = "SELECT * INTO [" & sheetName & "] FROM " & _
"OPENROWSET('Microsoft.Jet.OLEDB.4.0', " & _
"'Excel 8.0;Database=C:\clients\CTim\test2.xls;', " & _
"'SELECT * FROM [" & sheetName & "$]')"
Debug.Print strSQL
cn.Execute strSQL, lngRecsAff, adExecuteNoRecords