|
-
Dec 10th, 2010, 09:59 AM
#1
Thread Starter
PowerPoster
[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...
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Dec 10th, 2010, 10:52 AM
#2
Thread Starter
PowerPoster
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"];
===================================================
If your question has been answered, mark the thread as [RESOLVED]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|