Dataset does not return 1st row?

Posted on 2009-07-14
Last Modified: 2012-05-07
This might be easy but...
I've opened a CSV file using ADO, filled a DataSet from the result but I'm not getting the first row. Is this a 0 based thing?
cn = New ADODB.Connection

        cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & _

                "Data Source=" & strInputFilePath & ";" & _

                "Extended Properties='text;HDR=NO;FMT=Delimited'")

        'create a new recordset

        rsSource = New ADODB.Recordset

        rsSource.CursorLocation = ADODB.CursorLocationEnum.adUseClient

        rsSource.CursorType = ADODB.CursorTypeEnum.adOpenStatic

        rsSource.LockType = ADODB.LockTypeEnum.adLockBatchOptimistic

        rsSource.Open("SELECT * FROM [" & System.IO.Path.GetFileName(strInputFile) & "]", cn)

        rsSource.ActiveConnection = Nothing


        Dim daDataAdapter As New System.Data.OleDb.OleDbDataAdapter()

        Dim dsDataSet As New DataSet()

        Dim drRow As DataRow

        daDataAdapter.Fill(dsDataSet, rsSource, System.IO.Path.GetFileName(strInputFile))


        Dim lngMaxRows As Long = dsDataSet.Tables(0).Rows.Count

        Dim sw As StreamWriter

        Dim dcColumn As DataColumn


        sw = New StreamWriter(strOutputFile)

        'Loop through Input file dataset

        For Each drRow In dsDataSet.Tables(0).Rows

            For Each dcColumn In dsDataSet.Tables(0).Columns

                If dcColumn.ColumnName.ToString = "SEQ_NO" Then

                    'format this field

                    str = str & drRow("SEQ_NO").ToString("00000000")


                    str = str & drRow(dcColumn.ColumnName) & Chr(9)

                End If




Open in new window

Question by:wessir
  • 2
LVL 41

Expert Comment

ID: 24854150
Do you mean your query itself is not returning the first row?
Is the dsDataSet.Tables(0).Rows.Count returning right count?


Author Comment

ID: 24854546
I don't know if it's not returning all or if the dataset isn't filled properly.  dsDataSet.Tables(0).Rows.Count returns 999 instead of the 1,000 records in the original CSV file.  The output file is missing the first record so it seems the 999 count is correct.

Accepted Solution

wessir earned 0 total points
ID: 24854589
I added the following line to my Schema.ini file and that took care of it...

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now