isnull and ""

Discussion in 'ASP General' started by Steven Scaife, Sep 14, 2004.

  1. I have a quick question i tried searching google but couldn't find anything

    What is the difference between not isnull(val) and <> ""

    can this statement be reduced from

    If NumberDep <> "" or not isnull(NumberDep) then HBinsertSQL = ",
    NoOfDependants = " & NumberDep

    to

    If not isnull(NumberDep) then HBinsertSQL = ", NoOfDependants = " &
    NumberDep

    I would like to know what the difference is and if possible any links that
    have a good description

    thanks in advance
     
    Steven Scaife, Sep 14, 2004
    #1
    1. Advertising

  2. Steven Scaife

    John Guest

    There are several articles on the net. IsNull in Jet is other than in Sql
    etc...
    If you want to avoid IsNull, then fill in the Default value of the fields as
    "", otherwise it will be NULL and you have to check on IsNull and "".
     
    John, Sep 14, 2004
    #2
    1. Advertising

  3. Steven Scaife wrote:
    > I have a quick question i tried searching google but couldn't find
    > anything
    >
    > What is the difference between not isnull(val) and <> ""


    Null means that the content of val is unknown.
    "" means that the content of val is ""

    See the difference? With null, we don't know what it contains. With "", we
    know what it contains.
    This has a little more information:
    http://blogs.msdn.com/ericlippert/archive/2003/09/30/53120.aspx
    followed by http://blogs.msdn.com/ericlippert/archive/2003/10/01/53128.aspx

    >
    > can this statement be reduced from
    >
    > If NumberDep <> "" or not isnull(NumberDep) then HBinsertSQL = ",
    > NoOfDependants = " & NumberDep
    >
    > to
    >
    > If not isnull(NumberDep) then HBinsertSQL = ", NoOfDependants = " &
    > NumberDep
    >


    I like to use
    If len(NumberDep) > 0 then

    Since the length of null is null, it will never be greater than zero. And
    since the length of "" is zero, this case will also be handled.

    I only use IsNull if different actions need to be taken depending on
    whether the test value is null or if it contains ""

    Bob Barriws

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Sep 14, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. EDOnLine

    IsNull Test ???

    EDOnLine, Dec 3, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    1,336
    mikeb
    Dec 4, 2003
  2. D. Shane Fowlkes

    Is IsNull supported in ASP.NET?

    D. Shane Fowlkes, Dec 18, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    25,396
    D. Shane Fowlkes
    Dec 18, 2003
  3. Brent

    SQLServer IsNull() & DataReader

    Brent, Apr 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,392
    Cowboy \(Gregory A. Beamer\)
    Apr 29, 2004
  4. =?Utf-8?B?Tkg=?=

    simple problem - need something like IsNull

    =?Utf-8?B?Tkg=?=, Sep 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    437
    =?Utf-8?B?Tkg=?=
    Sep 5, 2005
  5. Generic Usenet Account

    isNull() method a good idea?

    Generic Usenet Account, Aug 1, 2005, in forum: C++
    Replies:
    12
    Views:
    608
    benben
    Aug 3, 2005
Loading...

Share This Page