Results 1 to 4 of 4

Thread: IsDBNull

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    12

    IsDBNull

    I have some code that checks for a null value

    If IsDBNull(Rec1.Fields("new_address2")) = true Then

    End If

    Everytime this code is reached, even if it is null, it will never step into the If statement. I have tried to look at all the examples on this site but nothing talks about pulling null values from databases and checking them. Thanks

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    A zero-length string does not equate to DBNull.

    Check the example code given at MSDN:

    http://msdn.microsoft.com/library/de...afctIsNull.asp

    Anyway...
    you either have to test for it on the SQL server, or test for it in the VB code...

    Testing on the client-side:
    VB Code:
    1. If Rec1.Fields("new_address2") = String.Empty  Then

    Testing on the DB-side:
    Code:
    new_Address2 varchar(50)= null
    VB Code:
    1. If Rec1.Fields("new_address2") Is DbNull.Value Then
    Last edited by nemaroller; Apr 13th, 2004 at 03:58 PM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    12

    Ok.

    I looked at that page and I still have issues. When I step through the code the value of Rec1.Fields("original_address2").Value is {System.DBNull}. How do I do this?

  4. #4
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    i think u are missing 'Value' keyword in ur code.

    VB Code:
    1. If IsDBNull(Rec1.Fields("new_address2")[B].Value[/B]) = True Then
    2.  
    3. End If

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