Home All Groups Group Topic Archive Search About
Author
10 May 2006 1:49 PM
ad
I use the new feature of TableAdapter in VS2005.
There is a DataSet name dsSt, I want to fetch the value of a field in a
datarow.
I use the code:

   foreach (dsSt.StRow rowSt in dtSt.Rows)
   {
        int iNum=rowSt.Num
        ...

But when rows.Num is a DBNull, it cause an Exception.

How can I determinate if rowSt.Num is a DBNull before I assigned it to a
variable?

Author
10 May 2006 2:13 PM
Sericinus hunter
ad wrote:
Show quote
> I use the new feature of TableAdapter in VS2005.
> There is a DataSet name dsSt, I want to fetch the value of a field in a
> datarow.
> I use the code:
>
>    foreach (dsSt.StRow rowSt in dtSt.Rows)
>    {
>         int iNum=rowSt.Num
>         ...
>
> But when rows.Num is a DBNull, it cause an Exception.
>
> How can I determinate if rowSt.Num is a DBNull before I assigned it to a
> variable?

    There should be rowSt.IsNumNull() method generated paired with rowSt.SetNumNull().

AddThis Social Bookmark Button