Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Testing for Null values with a DataReader
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00948865
Message ID:
00948869
Vues:
23
Mat,

I haven't used a DataReader, but based on how stuff works with DataSets, I bet you probably have to do something like this:
IDataReader dr = this.ExecReader(SelectCmd, out conn);
while (dr.Read())
{
  if (dr.Item[0] != DBNull.Value)
    MyString = dr.GetString(0);
}
Something like that anyway ... I'm not sure of the syntax and I haven't actually tried it, but see if something along these lines would work for you.

~~Bonnie




>I am getting the following error message:
>
>"Data is Null. This method or property cannot be called on Null values."
>
>The code causing this problem is something like this:
>
>IDataReader dr = this.ExecReader(SelectCmd, out conn);
>while (dr.Read())
>{
>MyString = dr.GetString(0);
>}
>
>This is processing a couple of thousand records and then errors with the message. How can I test for Null before calling GetString?
>
>Thanks in advance for any help!
>
>Kind Regards,
>
>Mat
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform