Hi,
I am using this code to import a .csv file selected by user ( the textbox Cmbhavfile holds the path for this file) to a table in Access but get an error:
[Microsoft] [ODBC Text Driver] Syntax error in From Clause
I don't understand what is wrong because the same code is running well on a different mavhine.
Any help will be greatly appreciated.
Thanks!
Dheeraj
Dim a As Integer, strCSV As String, strsql As String
strCSV = Cmbhavfile.Text
Set objConn = New ADODB.Connection
With objConn
.CursorLocation = adUseClient
.ConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)}; Initial Catalog=" & strCSV & ";"
.Open ("Provider=MSDASQL.1;Persist Security Info=False;Data Source=Text Files"
End With
strsql = "SELECT * INTO cmbhav4 IN 'D:\VCare\Project\bhav.mdb' FROM " & strCSV
objConn.Execute (strsql)
objConn.Close
I am using this code to import a .csv file selected by user ( the textbox Cmbhavfile holds the path for this file) to a table in Access but get an error:
[Microsoft] [ODBC Text Driver] Syntax error in From Clause
I don't understand what is wrong because the same code is running well on a different mavhine.
Any help will be greatly appreciated.
Thanks!
Dheeraj
Dim a As Integer, strCSV As String, strsql As String
strCSV = Cmbhavfile.Text
Set objConn = New ADODB.Connection
With objConn
.CursorLocation = adUseClient
.ConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)}; Initial Catalog=" & strCSV & ";"
.Open ("Provider=MSDASQL.1;Persist Security Info=False;Data Source=Text Files"
End With
strsql = "SELECT * INTO cmbhav4 IN 'D:\VCare\Project\bhav.mdb' FROM " & strCSV
objConn.Execute (strsql)
objConn.Close