Click here to Skip to main content
15,894,129 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to solve datareader

VB
Do While dr.Read()
            Dim dataRow As DataRow = dt.NewRow()

            For i As Integer = 0 To listCols.Count - 1
                dataRow((CType(listCols(i), DataColumn))) = dr(i) '"<br />" & dr(i) & "<br /><br />"
            Next i
            dt.Rows.Add(dataRow)
        Loop


when i use this code in our function and saw in watch window it shows first row in dr.read() point after next point it shows the next row

my problem is after executing the code it show the one record less than reading the record.
how to solve it..

thanks in advance..
Posted

Looks like you have a
odr.Read()
statement before the while loop some where and that is why when you enter the while loop it shows the first record and the the moment passing
Do While dr.Read()
it shows the second record hence missing the first record for you.

Please check your code before the while loop and make sure there is no
odr.Read()
 
Share this answer
 
use
datatable.load method and pass in the datareader object.

Refer this
http://msdn.microsoft.com/en-us/library/system.data.datatable.load.aspx#Y1089[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900