Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Testing for Null values with a DataReader
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00948865
Message ID:
00948914
Views:
15
This message has been marked as the solution to the initial question of the thread.
Mat,

>System.Data.IDataReader does not contain a definition for Item

That's because you're using the Interface (IDataReader) rather than OleDbDataReader or SqlDataReader (sorry, I didn't notice that in your original post). It seems strange that they wouldn't have the Item property in the Interface, but it doesn't look like it's there. Do you need to use IDataReader or can you use either the OleDb or Sql DataReader?

~~Bonnie



>Bonnie,
>
>Thank you for the reply! I thought I could do something like this, but if I try dr.Item[0] I get the following compile error:
>
>System.Data.IDataReader does not contain a definition for Item
>
>I have looked through the help files and a couple of books I have, but I can find the correct syntax.
>
>Kind Regards,
>
>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
>>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform