Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message display when query returns no records 1

Status
Not open for further replies.

sacsadmin

IS-IT--Management
Oct 16, 2002
39
US
Currently I have the code listed below. When the query runs the ASP code produces the correct output if there is a record match, if there is not, it just generates a blank screeen. How do you get a screen to display "no records found in search" instead of the empty screen. Is this done with an IIF statement. If so, is the empty search considered a Null response, or is my brain just full of Null?

Thanks in advance.

Current ASP file:


<html>
<head>
<title>Auction Results</title>
</head>
<body bgcolor=&quot;black&quot; text=&quot;white&quot;>
<%
Dim Conn, dbpath
Set Conn = Server.Createobject(&quot;ADODB.Connection&quot;)
dbpath =&quot;DBQ=&quot; & server.mappath(&quot;auctionresults.mdb&quot;)
Conn.open &quot;DRIVER={Microsoft Access Driver (*.mdb)}; &quot; & dbpath
'Response.Write &quot; Conn.open &quot; & &quot;DRIVER={Microsoft Access Driver (*.mdb)}; &quot; & dbpath
Dim rs, pin, sqltxt
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
pin = request.form(&quot;customerno&quot;)
sqltxt = &quot;SELECT * FROM results WHERE customerno =&quot; & pin
rs.open sqltxt, Conn
Response.Write(&quot;<left>&quot;)
Response.Write(&quot;<TABLE BORDER=0>&quot;)
Do while not rs.EOF
Response.Write(&quot;<TR>&quot;)
Response.Write(&quot;<TD>&quot;)
Response.Write(rs(&quot;lotno&quot;))
Response.Write(&quot;</TD>&quot;)
Response.Write(&quot;</TR>&quot;)
rs.MoveNext
Loop
Response.Write(&quot;</TABLE>&quot;)
Conn.Close
Set rs=Nothing
Set Conn=Nothing
%>
</body>
</html>

 
if rs(&quot;lotno&quot;).EOF
response.write &quot;no records found&quot;
else
........
end if _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
I am trying to follow the logic of this. My understanding of an IF statements...If this is true do a, if this is false do b. So if I am already running a loop until EOF, where to I located the If statement. If I do as follows it won't display. My thought behind this is you do the loop if true and you report the no records message if the loop doesn't run. Obviously this wasn't the case.


Do while not rs.EOF
If rs.EOF
Reponse.write (&quot;no records found&quot;)
else
Response.Write(&quot;<TR>&quot;)
Response.Write(&quot;<TD>&quot;)
Response.Write(rs(&quot;lotno&quot;))
Response.Write(&quot;</TD>&quot;)
Response.Write(&quot;</TR>&quot;)
rs.MoveNext
end if
Loop
Response.Write(&quot;</TABLE>&quot;)

 
try
if rs.EOF then 'if EOF = true
Response.Write &quot;No records found to query&quot;
else ' if not at EOF then write records
Response.Write(&quot;<left>&quot;)
Response.Write(&quot;<TABLE BORDER=0>&quot;)
Do while not rs.EOF
Response.Write(&quot;<TR>&quot;)
Response.Write(&quot;<TD>&quot;)
Response.Write(rs(&quot;lotno&quot;))
Response.Write(&quot;</TD>&quot;)
Response.Write(&quot;</TR>&quot;)
rs.MoveNext
Loop
Response.Write(&quot;</TABLE>&quot;)
end if _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
onpnt:

You are outstanding! I was getting close, maybe in a few days I would have been able to get it right after I finished the box of oval-teen and sent off for the secret decoder ring.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top