Results 1 to 5 of 5

Thread: [Resolved]ADODB: Invalid use of null

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    13

    [Resolved]ADODB: Invalid use of null

    I had an error "invalid use of null". How to get away with this error?
    Last edited by vocalmind; Sep 12th, 2005 at 07:49 AM. Reason: Resolved

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: ADODB: Invalid use of null

    If it's on the VB side...

    strValue = rs(0).Value & ""

    or

    text1.Text = rs(0).Value & ""

    Concatenating an emptry string in VB will turn NULL into EMPTY strings. VB strings do not like null...

    It can be done other ways - but that is the way we prefer in our shop.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    13

    Re: ADODB: Invalid use of null when ACCESS fields is empty

    This the code line. It means that if the postal code fields has no data on ACCESS it will prompt an error invalid use of NULL. I want that if the ACCESS has an empty fields then TEXT label is also empty.

    txtPost.Text = rs.Fields("postal code")

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: ADODB: Invalid use of null

    Then do this:

    Code:
    txtPost.Text = rs.Fields("postal code") & ""
    The & "" will turn the database NULL value into an EMPTY string - which is what you say you want.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    13

    Re: [Resolved]ADODB: Invalid use of null

    Thanks szlamany.

    Phew...it's still along way to go.

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