Avatar of bfuchs
Flag for United States of America

asked on 

Error reading text file from VBA

Hi Experts,

I have a code that reads data from a text file and imports into a SQL table, however when some records contains a comma as part of the data then the data gets truncated there and the code fails.
The code below is used:
   conn.Open "DRIVER={Microsoft Text Driver (*.txt; *.csv)};DBQ=\\myserver\E\XFER;"
   rs.Open "SELECT * FROM [myfile.txt]", conn, adOpenStatic, adLockReadOnly, adCmdText

Open in new window

I am also attaching the sample of data file.
Any idea how to make it work is appreciated.
Microsoft AccessVisual Basic Classic

Avatar of undefined
Last Comment

8/22/2022 - Mon