?
Solved

ADODB Recordset is skipping the first line.

Posted on 2006-11-02
7
Medium Priority
?
325 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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