Generated DataTables and handling null values

  • Thread starter Thread starter jehugaleahsa
  • Start date Start date
J

jehugaleahsa

Hello:

Is there a way to handle null values for ints, DateTime, etc. in
generated DataTables?

It seems it is not something the Microsoft crew thought of. That is
hard for me to believe.

Thanks,
Travis
 
Travis,

While I don't like it, for typed data sets, you have to use the
Is<column>Null property to determine if the value in a particular column is
null. It sucks, trust me.

If you are checking against a value in a plain old data row, then you
can check against the static Value field on the DBNull class. If the value
in the field is null, then it will return true when compared to that.
Otherwise, you can get your scalar value.
 
Hello:

Is there a way to handle null values for ints, DateTime, etc. in
generated DataTables?

It seems it is not something the Microsoft crew thought of. That is
hard for me to believe.

Thanks,
Travis
Another option is if(String.IsNullOrEmpty(dr[n].ToString()))
before trying to use the value.
nullable types may also be of use to you for your value types.
hth
Bob
 

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

Back
Top