Solved

ADODB Recordset is skipping the first line.

Posted on 2006-11-02
7
309 Views
Last Modified: 2007-12-19
I am using ADO to read a comma-delimited file.  This is working fine except that it is skipping the first line in the file.  I have already set the connection string to no header row.  Sample code is below.

set conn = CreateObject("ADODB.Connection")
set rs = CreateObject("ADODB.Recordset")

connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & s.GetEnvironmentString("Directory", True) & _
          "\;Extended Properties=" & Chr(34) & "text;HDR=NO;FMT=Delimited" & Chr(34)

conn.Open connString

rs.Open "SELECT * FROM " & fileDirectory & fileB, conn, adOpenStatic, adLockOptimistic, adCmdText

Do While Not rs.eof
    .....Code here
   
    rs.MoveNext
Loop


The RecordCount returned is actually correct for the file but it starts with the second line in the file and the last record is null filled.  Any help with this is much appreciated.
0
Comment
Question by:jmwheeler
7 Comments
 
LVL 1

Expert Comment

by:dacz
ID: 17859024
try to insert rs.MoveFirst in your Do-While Loop, for example:

Do While Not rs.eof

    rs.MoveFirst

    .....Code here
   
    rs.MoveNext

Loop
0
 
LVL 1

Expert Comment

by:dacz
ID: 17859054
i want to edit my post:

try to insert rs.MoveFirst  after you get the recordsets, for example:

rs.Open "SELECT * FROM " & fileDirectory & fileB, conn, adOpenStatic, adLockOptimistic, adCmdText

If rs.RecordCount > 0 then

   rs.MoveFirst

End if


Do While Not rs.eof

    .....Code here
   
    rs.MoveNext

Loop
0
 
LVL 11

Author Comment

by:jmwheeler
ID: 17859974
That did not resolve the issue.  Thanks though.  Any other takers?
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 11

Author Comment

by:jmwheeler
ID: 17860094
Nevermind, I found the answer myself. I needed to add ColNameHeader=False to my schema.ini file.  Please close this question.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17863823
>>Please close this question.<<
Please do it yourself.  Here's how:

I answered my question myself. What do I do?
http://www.experts-exchange.com/help.jsp#hi70
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17897959
Closed, 250 points refunded.
DarthMod
Community Support Moderator
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question