Oct 4, 2004 #1 maswien Technical User Sep 24, 2003 1,286 CA I have a piece of code to test if the return column is null: If Not objDataReader.GetString(2) Is DBNull.Value Then ... end if I got error tells me that the cast is not valid! What's the correct way to test null? Thanks
I have a piece of code to test if the return column is null: If Not objDataReader.GetString(2) Is DBNull.Value Then ... end if I got error tells me that the cast is not valid! What's the correct way to test null? Thanks
Oct 4, 2004 #2 JignasuK Programmer Sep 4, 2004 25 US Try using something like below... If Not IsDBNull(objDataReader.GetString(2)) Then ... End If Jignasu Upvote 0 Downvote
Try using something like below... If Not IsDBNull(objDataReader.GetString(2)) Then ... End If Jignasu
Oct 5, 2004 Thread starter #3 maswien Technical User Sep 24, 2003 1,286 CA It doesn't work eithor, the same error. Actually the value for objDataReader.GetString(2) is a '' but not a null in the database, in any case above statement shouldn't fail. it's so weird! Upvote 0 Downvote
It doesn't work eithor, the same error. Actually the value for objDataReader.GetString(2) is a '' but not a null in the database, in any case above statement shouldn't fail. it's so weird!
Oct 5, 2004 1 #4 RiverGuy Programmer Jul 18, 2002 5,011 US Instead of objDataReader.GetString(2), use objDataReader.Item(2) Upvote 0 Downvote