SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Script not returning value in ELSE

    Hello,

    First time poster and fairly new to ASP programming.

    I am trying to add a functionality that checks if a field is empty, if so return a set value.
    Here is what i have got so far:
    Code:
    'rsGlobalWeb is basicly declared the same as rsBackup just in a different asp file with also the db connection.
    <%  If rsGlobalWeb("Serial") <> "" Then
    		response.write("<td>" & rsGlobalWeb("Serial") & "</td>")
    	Else
    		SqlBackup = "SELECT * FROM CMDBbackup WHERE Naam_Cattools = '" & rsGlobalWeb("Device_name") & "'" 
    		Set rsBackup = Server.CreateObject("ADODB.Recordset")
    		rsBackup.Open SqlBackup, dbGlobalWeb, 3
    		
    		If Not rsBackup.EOF Then
    			If Not IsNull(rsBackup("Serial")) And (rsBackup("Serial") <> "") Then
    				response.write("<td>" & rsBackup("Serial") & " (backup)</td>")
    			Else
    				response.write("<td>No historical data found</td>")
    			End if
    		End if
    	End if
    %>
    Now for the problem: when there is a value in the backup database it shows that value combined with the "(backup)" behind it. So that is working fine. The problem is that when there is no value found, it does not return anything.

    I have tried do to some google searches but perhaps i am overlooking something here.
    Any thoughts what it could be?

    Thanks in advance,
    Erik

  2. #2
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Problem solved:
    End if
    Else
    response.write("<td>No historical data found</td>")

    Moved the first End If to before the ELSE and it works now


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •