False While Statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following while statement in my code

While dataReader.read(
‘Do Stuffâ€
End Whil

The dataReader contains 19 rows of data, but the while loop continues and fails on a 20th loop. I have attached a debugger and watched the value of dataReader.read go from True to False after the 19th loop. For some strange reason the loop continues after "While dataReader.read" becomes false

Any fixes, tips, or suggestions are greatly appreciated

Ty Millwe
(e-mail address removed)

--Actual Code-

Dim dr2 As SqlDataReade
dr2 = SqlHelper.ExecuteReader(oConn, CommandType.Text, sql

While dr2.Rea

If Not IsDBNull(dr2("hpa")) The
Me.dg.Items.Item(i).Cells(5).Text = CStr(dr2("hpa")
Els
Me.dg.Items.Item(i).Cells(5).Text = Nothin
End I

If Not IsDBNull(dr2("comments")) The
Me.dg.Items.Item(i).Cells(9).Text = CStr(dr2("comments")
Els
Me.dg.Items.Item(i).Cells(9).Text = Nothin
End I

CalcHLP(i
CalcATL(i
'CalcHB(i
i = i +
End Whil
 
How about slightly changing the code like this

Do While datareader.read(
' do somethin
End While
 
Back
Top