Dear Sir,
I have accessed one field from database with datareader.Now I want to check it and the accordinngly want to increase or decrease it.
(e.g. If we got 4 from database and this 4 has been stored in the datareader object(e.g.dr[0] contains 4) now i want to check it aginst 5 if it is 5 then display 6).
I tried below mentioned code for the same -
SqlDataReader dr = null;
dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
if (dr.GetInt32(0) == 5)
{
Response.Write("6");
}
}
}
But it is giving Exception in if condition is that Specified cast is not valid.
How it is possible.
Pls help me out.