[RESOLVED] Error in casting a number
I hate to keep asking such newbie questions here, but...
I have my data reader working. However, whenever I try to work with integer values from the database, I get this err:
"When casting from a number, the value must be less than infinity"
Code:
while (rdr.Read())
{
int shift = (int)rdr["shift"];
string shift2 = shift.ToString();
int empnum = (int)rdr["empnum"];
string empnum2 = empnum.ToString();
string namel = (string)rdr["namel"];
string namef = (string)rdr["namef"];
MessageBox.Show(shift2 + " " + empnum2 + " " + namel + "," + namef);
}
It happens at
int shift = (int)rdr["shift"];
the string casting works fine...
Re: Error in casting a number
This worked
Code:
string shift = null;
shift = rdr["shift"].ToString();
string empnum = null;
empnum = rdr["empnum"].ToString();
string namel = (string)rdr["namel"];
string namef = (string)rdr["namef"];