Lactose
Lactose

Reputation: 695

Selecting Data from Excel Spreadsheet Doesn't get First Row

I'm using an OleDbDataReader to loop through my imported excel file and it gets everything in the file except for the first row. How can I specify that I want to see this header row?

        strSQL = "SELECT * FROM [" & firstSheetName & "]"

        Dim myCommand As New OleDbCommand(strSQL, myConnection)
        Dim myDba As OleDbDataReader

        myDba = myCommand.ExecuteReader
        s = ""
        While myDba.Read()
            For i = 0 To myDba.FieldCount - 1
                s &= myDba.Item(i) & vbTab
            Next
            s &= vbCrLf
        End While

Upvotes: 1

Views: 826

Answers (1)

Olaf
Olaf

Reputation: 6289

You should specify that your spreadsheet doesn't have header: HDR=No .

Upvotes: 1

Related Questions