Catch Nulls and blanks?

Discussion in 'ASP General' started by jason, Nov 14, 2003.

  1. jason

    jason Guest

    How does one accurately catch NULL or blank fields in ASP....it appears this
    If statement does not appear to be able to catch it...why is this...I appear
    to have covered all the necessary conditions but it does not seem able to
    pick it up:

    If IsNull(Owner_ID) or Owner_ID="" or IsEmpty(Owner_ID) or Owner_ID = Null
    Then

    Response.Write "A null value has been picked up in the Owner_ID field"

    End If
     
    jason, Nov 14, 2003
    #1
    1. Advertising

  2. jason

    Ray at Guest

    If don't care about NULL vs. empty, you can do:

    Owner_ID = YourRecordSet.Fields.item("whatever").Value & ""
    If Owner_ID = "" Then Response.Write "The value is null or empty."

    Ray at work

    "jason" <> wrote in message
    news:...
    > How does one accurately catch NULL or blank fields in ASP....it appears

    this
    > If statement does not appear to be able to catch it...why is this...I

    appear
    > to have covered all the necessary conditions but it does not seem able to
    > pick it up:
    >
    > If IsNull(Owner_ID) or Owner_ID="" or IsEmpty(Owner_ID) or Owner_ID = Null
    > Then
    >
    > Response.Write "A null value has been picked up in the Owner_ID field"
    >
    > End If
    >
    >
     
    Ray at, Nov 14, 2003
    #2
    1. Advertising

  3. jason

    Randy Rahbar Guest

    > How does one accurately catch NULL or blank fields in ASP....it appears
    this

    I usually test for length...

    if len(yourVariable) > 0 then
    'it's not null or blank
    else
    'it is
    end if
     
    Randy Rahbar, Nov 14, 2003
    #3
  4. jason

    Randy Rahbar Guest

    > if len(yourVariable) > 0 then

    This should probably be...
    if len(trim(yourVariable)) > 0 then
     
    Randy Rahbar, Nov 14, 2003
    #4
  5. jason

    jason Guest

    Thanks.


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > If don't care about NULL vs. empty, you can do:
    >
    > Owner_ID = YourRecordSet.Fields.item("whatever").Value & ""
    > If Owner_ID = "" Then Response.Write "The value is null or empty."
    >
    > Ray at work
    >
    > "jason" <> wrote in message
    > news:...
    > > How does one accurately catch NULL or blank fields in ASP....it appears

    > this
    > > If statement does not appear to be able to catch it...why is this...I

    > appear
    > > to have covered all the necessary conditions but it does not seem able

    to
    > > pick it up:
    > >
    > > If IsNull(Owner_ID) or Owner_ID="" or IsEmpty(Owner_ID) or Owner_ID =

    Null
    > > Then
    > >
    > > Response.Write "A null value has been picked up in the Owner_ID field"
    > >
    > > End If
    > >
    > >

    >
    >
     
    jason, Nov 14, 2003
    #5
  6. jason

    jason Guest

    Thanks.

    "Randy Rahbar" <rvrahbar@_JUNK_hotmail.com> wrote in message
    news:...
    > > if len(yourVariable) > 0 then

    >
    > This should probably be...
    > if len(trim(yourVariable)) > 0 then
    >
    >
     
    jason, Nov 14, 2003
    #6
  7. jason

    Venkat Guest

    You can user one more property provided in VB and VB Script i.e.,
    vbNullString and then try.

    If IsNull(ColumnName) Or ColumnName <> "" Or ColumnName <> vbNullString
    Then
    Do Something
    End If

    DEVBuilder.org, http://www.DEVBuilder.org
    ASP,ASP.NET,VB.NET,PHP,Java,and SQL Support, all in one place.
     
    Venkat, Nov 15, 2003
    #7
  8. jason

    Steven Burn Guest

    If Len(Owner_ID) = 0 Then
    'Do something
    Else
    'Do something else
    End If

    --

    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!

    Disclaimer:
    I know I'm probably wrong, I just like taking part ;o)
    jason <> wrote in message
    news:...
    > How does one accurately catch NULL or blank fields in ASP....it appears

    this
    > If statement does not appear to be able to catch it...why is this...I

    appear
    > to have covered all the necessary conditions but it does not seem able to
    > pick it up:
    >
    > If IsNull(Owner_ID) or Owner_ID="" or IsEmpty(Owner_ID) or Owner_ID = Null
    > Then
    >
    > Response.Write "A null value has been picked up in the Owner_ID field"
    >
    > End If
    >
    >
     
    Steven Burn, Nov 15, 2003
    #8
    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. John Black
    Replies:
    8
    Views:
    4,160
    Xenos
    Aug 20, 2004
  2. Replies:
    5
    Views:
    460
    Kent Johnson
    May 2, 2006
  3. jalkadir
    Replies:
    6
    Views:
    428
    jalkadir
    Oct 15, 2005
  4. Adam
    Replies:
    9
    Views:
    576
    red floyd
    Feb 2, 2006
  5. Dave Anderson

    Stored Procedure as method of Connection and NULLs

    Dave Anderson, Apr 5, 2006, in forum: ASP General
    Replies:
    2
    Views:
    115
    Bob Barrows [MVP]
    Apr 5, 2006
Loading...

Share This Page