Not display a text if the DB record is empty

  • Hi everyone!

    I'm building ASP pages where there will be displayed information brought -- in a looping process -- from SQL Server databases - for each "turn" of the loop, there will be "titles" before each kind of info: for instance:

    Response.write "Your fax number: " & <objRS("faxnr")>

    ... but sometimes, some fields of a record may NOT contain any data, or a NULL (if those information are not "required").

    So, the problem is specifically this: in this case, the "title" will appear ...followed by nothing!!!?!?...

    Then I ask You gurus:

    - HOW can I force that piece of text (what a called "title") NOT to appear, not to be displayed-IF-its correspondent field is empty, or NULL?

    I'd like to thank You in advance, for your attention.

    Dalton Gilson, Rio

  • use an if statement to determine whether the field is not null or not empty:

    if !isNull(objRS("faxnr")) or objRS("faxnr") > "" then

    Response.write "Your fax number: " & <objRS("faxnr")>

    end if

    NB Have not checked the sytax but I trust you get the idea.

    Jeremy

  • Jeremy

    1. unfortunately, it did not accept the "!" before "isNull"!

    2. On the other hand, trying -without- the "!", it rejected the "<" and the ">" around the "objRS("faxnr")" expression at the "then" option (but this wouldn't be -The- problem).

    I really did not "get the idea" of WHY the system rejected it...

    Sincerely yours

    Dalton

  • Dalton,

    Try this:

    if not isNull(objRS("faxnr")) and objRS("faxnr") <> "" then

    Response.write "Your fax number: " & objRS("faxnr")

    end if

    Jeremy

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply