websss
asked on
Datareader - checking for system,indexOutOfRangeException
I have a data reader that has this code
This works fine if results are returned, but if the data reader has no results, it breaks
I tried using .HasRows, but it always has rows for some reason
Anyway, what code do i need to check for this out of range exception?
while (dr.Read())
{
if (Convert.ToInt16(dr[0]) > 0) {
recordsReturned = 1;
}
This works fine if results are returned, but if the data reader has no results, it breaks
I tried using .HasRows, but it always has rows for some reason
Anyway, what code do i need to check for this out of range exception?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.