In addition to using Kevin's suggestion of the int.Parse() method, you could also do an explicit cast:
MyNum = (int)dr["num_nexta"];
In either case, if your column contains a DBNull.Value, it'll blow up with the "specified cast invalid" error, so be aware of the fact that you may have to test your data.
~~Bonnie
>Hi.
>I am trying to read a record form a table, and display the contents of one field. (There is only one row in the table..coming from a dataset)
>The field is type numeric.
>
>My code is:
>
>
>DataTable dt = this.dsIFNUM.Tables["IFNUM"];
>
>// Go to the first record on the table
>DataRow dr = dt.Rows[0];
>
>// Store field contents to a variable
>int MyNum;
>MyNum = dr["num_nexta"];
>MessageBox.Show(Convert.ToString(MyNum));
>
>
>I am getting a 'Cannot Implicitly convert type 'Object' to 'Int'
> on the MyNum = dr["num_nexta"] line
>I am trying to store the value of the num_nexta field into Mynum field
> and then display the contents
>
>Any help appreciated.
>
>Regards,
>Gerard
>
>
>
>
>
>