Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    outside the rim

    Unanswered: ADO skips first line of text data file


    Using ADO to read a text data file, the recordset omits the first row of the text file every time.

    File is a .dat file, tab delimited, no header row.

    Got all my ducks in a row:
    1) Write a schema.ini
    2) Make sure the extension is not excluded in the Jet Text registry key
    3) Setup the connection properly (per MSDN Scripting help)

    Works nicely, except the fist line of data is missing. File contains 78 rows of data, Jet is skipping the first line every time and reporting 77 rows.

    1) Adding a blank row, as suggested in this forum, is not an option - the data files are machine generated are not to be altered by other processes.
    2) I could do it the old fashion way of importing and splitting into arrays, but this is a database function and ADO should be able to handle it.

    Code samples:
        adoCON.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath & ";Extended Properties=""text;HDR=NO;FMT=Delimited;"";"
        rsSrc.Open "Select * From " & sFile, adoCON, adOpenStatic, adLockOptimistic, adCmdText
    sPath is a string containing the path, including the trailing \
    sFile is a string containing the file name.

    Any ideas?

  2. #2
    Join Date
    Jan 2007
    Provided Answers: 12
    I've seen the option to not import the first row of a data file before - generally because the file might contain column headers...
    I suggest you google up on not importing column heads and work it backwards - at least, that's where I'd start

    Good luck!
    Home | Blog

  3. #3
    Join Date
    Apr 2004
    outside the rim
    ok, finally found it. The HDR=No parameter in the connection statement is apparently ignored, which begs the question of why ADO even has that parameter.

    In any case, using ColNameHeader=False in the Schema.ini file (not HRD=No, which is what I had) corrected the problem.
    have fun!

    Todd S.
    click to email

    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET

    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  4. #4
    Join Date
    Feb 2004
    One Flump in One Place
    I think that if you have a schema file then your extended properties in your connection string are ignored. Dump the schema file and the HDR option should work fine. Of course, your import would fail though

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts