By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,676 Members | 1,636 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,676 IT Pros & Developers. It's quick & easy.

Generated DataTables and handling null values

P: n/a
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
Nov 27 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<je**********@gmail.comwrote in message
news:3a**********************************@r60g2000 hsc.googlegroups.com...
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
Nov 27 '07 #2

P: n/a
On Mon, 26 Nov 2007 20:03:13 -0800 (PST), "je**********@gmail.com"
<je**********@gmail.comwrote:
>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
Nov 27 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.