[RESOLVED] IsDBNull With DataReader
I need to set null instances of my records to "Contact Us" in a VB app.
Here are my Dims...
Dim contactText As String = "Contact School"
Dim myData(7) As String
There's already a global datareader I'm tapping into to get queries so I'm stuck with a datareader and trying this:
myData(0) = IIf(dr.IsDBNull(0), contactText, CStr(dr.GetValue(0)))
This seems to work but is a lot of extra code and it makes no sense that IIf would not work to me...
If dr.IsDBNull(0) Then
myData(0) = contactText
Else
myData(0) = CStr(dr.GetValue(0))
End If
Read http://www.vbforums.com/showthread.php?t=394527 but couldn't figure it out.
The error I get is: dr.IsDBNull(0): 'dr.IsDBNull' is not declared or the module containing it is not loaded in the debugging session.
Thanks for any clues,
Andrew
Re: IsDBNull With DataReader
Ok, I had to CStr the whole thing instead of doing them all separately...
myData(0) = CStr(IIf(dr.IsDBNull(0), contactText, dr.GetValue(0)))