I have a web app connecting to a SQL Server db. I use a stored procedure with a datareader to populate a listbox with a row for each record occurring on a certain date. I am using the following while loop for this:
While drGetPMs.Read
lbPMByDate.Items.Add(New ListItem(drGetPMs("EHKey"
& " " & drGetPMs("PMType"
& " " _
& drGetPMs("DatePM"
& " " & drGetPMs("Status"
& " " & drGetPMs("Meter"
, _
drGetPMs("PMUID"
))
End While
If there are 6 rows returned by the stored procedure, the listbox shows 5, leaving out the first record. When debugging, I can see the loop executing fully 5 times; however, on the 6th time the loop exits after the "while drGetPMs.Read" line.
The results do not show the first record from the result set of the stored procedure. Why is my while loop skipping the first row?
Any direction most appreciated!
Jason
While drGetPMs.Read
lbPMByDate.Items.Add(New ListItem(drGetPMs("EHKey"
& drGetPMs("DatePM"
drGetPMs("PMUID"
End While
If there are 6 rows returned by the stored procedure, the listbox shows 5, leaving out the first record. When debugging, I can see the loop executing fully 5 times; however, on the 6th time the loop exits after the "while drGetPMs.Read" line.
The results do not show the first record from the result set of the stored procedure. Why is my while loop skipping the first row?
Any direction most appreciated!
Jason