|
-
Aug 18th, 2006, 03:19 PM
#1
Thread Starter
New Member
[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
-
Aug 18th, 2006, 03:24 PM
#2
Thread Starter
New Member
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)))
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|