Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I check for DbNull
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01102095
Message ID:
01102122
Vues:
21
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform