[dba-VB] Text File Into Access Using Visual Basic 6

MartyConnelly martyconnelly at shaw.ca
Wed Jan 28 10:39:07 CST 2004

For a quick and dirty on a csv text file.
With a Jet install you should have access to TEXT OLEDB Provider
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
       "Data Source=c:\somepath\;" & _
       "Extended Properties=""text;HDR=Yes;FMT=Delimited"""

The HDR = Yes indicates Column names are included in the file.

'Then open a recordset based on a select on the actual file

oRs.Open "Select * From MyTextFile.txt", oConn, _
         adOpenStatic, adLockReadOnly, adCmdText
HOWTO: Open Delimited Text Files Using the Jet Provider's Text IIsam

Seth Galitzer wrote:

>Have a look at the downloads on my website.  I have sample code for file
>I/O in VB.  The code was written for Access, but is generic enough it
>should work in VB without a problem.  I use DAO in there for database
>access, but you can easily substitue ADO if you prefer.
>On Wed, 2004-01-28 at 03:28, paul.hartland at fsmail.net wrote:
>>To all,
>>Can anyone tell me (preferably with sample code, if possible), what is the fastest way to import a .txt file into a predefined table in access via Visual Basic 6.
>>My .txt file contains roughly 365,876 records with two fields  Barcode, Price.  This has to be imported into an Access table also containing two fields Barcode (text), Price (Number, Double, Fixed, 2 decimal places).  
>>The .txt file is comma delimited.  Im using Access XP and Visual Basic 6.0 as the front-end.
>>Thanks in advance for any help as, this project needs to be ready for Monday morning
>>Paul Hartland
>>Freeserve AnyTime - HALF PRICE for the first 3 months - Save £7.50 a month 

Marty Connelly
Victoria, B.C.

More information about the dba-VB mailing list