Classic ASP Script not returning value in ELSE
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:
'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 (rsBac开发者_高级运维kup("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
Your Response.Write
statements are enclosed in an If Not rsBackup.EOF Then
statement.
Nothing will be written if there are no records in rsBackup
.
精彩评论