Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I check for DbNull
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
01102095
Message ID:
01102122
Views:
23
The simple answer to my question is use the autogenerated method to check for dbnull:
ds.AuditHistory[0].IsPcNameNull();
Einar

>I have a typed dataset where some of the columns in one of the tables allows nulls. The question is how can I find out if a a particular column in a row has a value of null?
>
>Well I figured out how to check for DbNull (by using IsDBNull()), but now I have a different (but yet related) questions.
>
>Why does this work:
>
>if (System.Convert.IsDBNull(ds.AuditHistory[0][ds.AuditHistory.PcNameColumn.Ordinal]))
>{
>	MessageBox.Show("Null");
>}
>else
>{
>	MessageBox.Show("not Null");
>}
>
>
>But this does not work:
>
>if (System.Convert.IsDBNull(ds.AuditHistory[0].PcName))
>{
>	MessageBox.Show("Null");
>}
>else
>{
>	MessageBox.Show("not Null");
>}
>
>
>Hmm after a little bit more research it turns out that the fine folks at M$ autogenerated this fine method to check for null
>
>ds.AuditHistory[0].IsPcNameNull();
>
>
>I should have paid closer attention to my intellisense as I was typing lol.
>
>Thanks,
>Einar
Semper ubi sub ubi.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform