How to manage DBNull

A

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?
 
S

Sericinus hunter

ad said:
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().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top