Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error importing CSV file to Access table using MS Text Driver

Status
Not open for further replies.

damotwani

MIS
May 31, 2003
19
0
0
IN
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
 
If the code is working on one machine and not the other, then you may have your ODBC drivers setup differently in you control panel on the computers. Check all the information for the ODBC drivers on the computer that works and verify the same setup on the one that is not working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top