sql vbscript     if record null then

Posted on 2007-07-19
Last Modified: 2008-01-09
I want to skip over a record if it is null so it does not print the section of the data

currently I have this which does not work

<% IF (NOT ISNULL (rs("OrgPhoneTTY"))) THEN %>
<div>TTY  <%=rs("OrgPhoneTTY")%></div>
<% end if %>

but it still prints the TTY if its empty
Question by:confused_coder
    LVL 58

    Accepted Solution

    Most likely it is not NULL but empty string. Try it this way ...

    <% IF (NOT ISNULL (rs("OrgPhoneTTY"))) THEN %>
    <% IF (TRIM(rs("OrgPhoneTTY")) <> "") THEN %>
    <div>TTY  <%=rs("OrgPhoneTTY")%></div>
    <% end if %>
    <% end if %>
    LVL 16

    Expert Comment

    Empty is different than null. Are you sure that rs("OrgPhoneTTY") is returning null and not just an empty string? What you can probably do is change it to this:

    <% IF (NOT rs("OrgPhoneTTY") <> "" ) THEN %>
    <div>TTY  <%=rs("OrgPhoneTTY")%></div>
    <% end if %>
    LVL 3

    Expert Comment

    Both previous expert comments could be correct.  if you go with amit's then you should do it all in 1 IF statement:

    <% If Not isNull(rs("OrgPhoneTTY")) OR rs("OrgPhoneTTY")<>"" Then %>
    <div>TTY  <%=rs("OrgPhoneTTY")%></div>
    <% End If %>

    ~ MastaLlama ~

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now