Often, you may have cause to read a comma-delimited, or some other
form of delimitation, into an ADO recordset. However, if your text
file doesn't contain header information, you may encounter odd
behavior in which ADO uses data in the first record as the recordset's
field names.
This glitch results because, by default, ADO assumes that each text
file will contain headers on the first row. So how do you indicate
otherwise? One hint can be found in the connection string generated by
Visual Basic when it connects to a text file, as seen here:
connCSV.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
As you can see, the connection string contains a section called
& "Data Source=" &
App.Path & ";" _
& "Extended
Properties='text;FMT=Delimited'"
Extended Properties, which indicates a delimited text file. By adding
a third argument to this section, we can tell ADO that the file doesn't
contain headers. The argument named HDR takes YES or NO as its sole
value. With this extra argument in place, the completed connection
string looks like this:
connCSV.Open "Provider=Microsoft.Jet" _
& ".OLEDB.4.0;Data
Source=" & App.Path _
& ";Extended
Properties='text;HDR=NO;" _
& "FMT=Delimited'"
Read text files into ADO recordsets
By James Crowley, published on 14 Jul 2001
| Filed in
You might also like...
VB 6 forum discussion
-
CorelDRAW VBA: cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline trace?
by dancemanj (0 replies)
-
client/server application using activex
by beautifulheart (0 replies)
-
System Error &H8007007E. The specifed module could not be found.
by swiftsafe (5 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
Send SMS with SMPP
by mmahmoud (0 replies)
VB 6 podcasts
-
Stack Overflow Podcast: Podcast #45 – Keeping it Sharp
Published 7 years ago, running time 0h54m
Our guest this week is Eric Lippert – language architect extraordinaire and famous for all his work at Microsoft in developing their languages Eric joined Microsoft right out of college and was originally working on VB It’s time for everyone’s favorite game: Name the Worst Feature of that Microso.
Comments