Sub ImportExcel(ByVal strFile As String)
Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim dtAdapter As New OleDbDataAdapter
Dim dt As New DataTable
Dim ds As New DataSet
Dim strConnString, strSQL As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("~/data/") & _
";Extended Properties='TEXT;HDR=Yes;FMT=Delimited;Format=Delimited(,)'"
strSQL = "SELECT * FROM " + strFile + " "
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(dt)
' InsertDB(dt, table)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
End Sub
error บันทัดที่ 18 ครับ Syntax error in FROM clause.