0

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
%>

Edited by MaddTechwf: Updated code

2
Contributors
14
Replies
35
Views
3 Years
Discussion Span
Last Post by MaddTechwf
Featured Replies
  • 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. Read More

0

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

Edited by JorgeM

0

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

0

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.

0

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?

0

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
%>
0

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
0

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.

0

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...

0

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.

1

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.