I've written my SQL lookup and tested it and it works great. I'm having issues checking and displaying text that might be null.

Can anyone help me with this?

This is what I've written and does not work at all

<%
    While (Not rsUP.EOF)
%>
<h3 class="name">
<%
        If Not IsNull(rsUP("Name_Title")) Then
            Repsonse.Write(rsUP("Name_Title") + " ")
        EndIf

        Repsonse.Write(rsUP("Name_First"))

        If Not IsNull(rsUP("Name_Middle")) Then
            Repsonse.Write(" " + rsUP("Name_Middle"))
        EndIf

        Repsonse.Write(" " + rsUP("Name_Last"))

        If Not IsNUll(rsUP("Name_Suffix")) Then
            Repsonse.Write(" " + rsUP("Name_Suffix"))
        EndIf
%>
</h3>
<%
        rsUP.MoveNext
    Wend
    Set rsUP = Nothing
%>

Recommended Answers

All 14 Replies

its been a while working with classic asp in this capacity, but how about this...

IF (NOT ISNULL(rsUP("Name_Middle"))) THEN
   Repsonse.Write("Was not NULL")
ELSE
   Repsonse.Write("Was NULL")
END IF

Unfortunately that did not work.

So, the outcome was that you had an emtpy field and the response.write that was displayed on the screen was "was not NULL"?

No, I got a 500 error from IIS server. I ended up rewriting the code to write all the data from recordset to variable and then I use your code above and replace "Middle_Name" with MName and it worked. When I have multile IFs with multiple Repsonse.Write's it errors out though.

So the 500 error is note related to the IsNull approach, its a syntax error somewhere else in your code (i didnt decode that for you).

When I have multile IFs with multiple Repsonse.Write's it errors out though.

Again, there a syntax error issue there probably.

So you resolved this problem and you are good then?

No. I only got it working with a single IF statement.

Do you want to show updated code if you still need help?

Sorry, I got handed a last minute item yesterday. Here is my updated code.

<%
    While (Not rsUP.EOF)
        FName = rsUP("Name_First")
        MName = rsUP("Name_Middle")
        LName = rsUP("Name_Last")
        TName = rsUP("Name_Title")
        SName = rsUP("Name_Suffix")
%>
        <h3 class="name">
            <%
                IF NOT ISNULL(TName) THEN
                    Response.Write(TName & " ")
                END IF
                Response.Write(FName & " ")
                IF NOT ISNULL(MName) THEN
                    Repsonse.Write(MName & " ")
                END IF
                Response.Write(LName & " ")
                IF NOT ISNULL(SName) THEN
                    Repsonse.Write(SName)
                END IF
            %>
        </h3>
<%
        rsUP.MoveNext
    Wend
    Set rsUP = Nothing
%>

Is your intention only to check for NULL values on some of the variables and not all?

IF NOT ISNULL(TName) THEN
  Response.Write(TName & " ")
END IF

Response.Write(FName & " ")

IF NOT ISNULL(MName) THEN
  Repsonse.Write(MName & " ")
END IF

Response.Write(LName & " ")

IF NOT ISNULL(SName) THEN
  Repsonse.Write(SName)
END IF

That is correct. Certain fields are required and can't have null values. So there are only two that will always have values FName and LName.

I'm unable to reproduce the problem. I don't see why you don't have an issue with one if..response.write..end if but you do with multiples.

Usually, when I run into issues like this, I troubleshoot by removing unknowns... Database components, variables, etc.. And just use info that I know for sure and can test against. When that works, reintroduce variables, DB components, etc...

Okay, thanks JorgeM. I also had one other question. Can I have multiple RecordSet Lookups?

I'm needing to do multiple queries on the same page.

I finally got this working. I was able to dig up an old application that had recordsets in it. The way I was calling recordsets was different that it. Changed them and now it works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.