Avatar of bfuchs
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
    
   rs.MoveFirst
   a=rs.Fields(0)

Open in new window


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

Avatar of undefined
Last Comment
bfuchs

8/22/2022 - Mon