David,
Yes, you will have to call the static ToSingle method on the Convert
class, or call the static Parse method on the Single structure, like so:
// Convert from a string to a single.
float Convert.ToSingle(dtrBMail["var"]);
However, since you are converting to an integer, I would just call the
ToInt32 method.
If the field is one of these types already, then I would suggest a cast,
since the type is already that. This way, you don't have to execute more
code to get the same result.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Da***@web.com" <Da*********@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.com...
I need to assign data from a data reader to a variable. here is a simpiet
of
code,
OleDbDataReader dtrBMail = cmd.ExecuteReader();
if (dtrBMail.Read()){
int t_mob_var_send_no;
t_mob_var_send_no=
(int)dtrBMail["var"].ToSingle();
}
The error I receive in the last line is, CS0117: 'string' does not contain
a
definition for 'ToSingle'
How do I correct this?