Results 1 to 2 of 2

Thread: [RESOLVED] IsDBNull With DataReader

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    7

    Resolved [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

  2. #2

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    7

    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
  •  



Click Here to Expand Forum to Full Width