Click to See Complete Forum and Search --> : Help how do i make the o founds appear when no record found


tekboy
01-17-2006, 05:15 PM
Help how do i make the o founds appear when no record found
i trying to put in

else
response.write "No Records Found"


but it messed up the code



<!--#include file="dbconnection.asp"-->
<p><strong>Enter zip code or city below:</strong></p>
<form action="<%= strURL %>" method="get">
<input name="search" value="<%= strSearch %>" />
<input type="submit" />
</form>

<%
If strSearch <> "" Then

' Build our query based on the input.
strSQL = "SELECT * " _
& "FROM zipcode, NotifyMapping " _
& "WHERE City LIKE '" & Replace(strSearch, "'", "''") & "' " _
& "OR Zip LIKE '" & Replace(strSearch, "'", "''") & "' " _
& "ORDER BY MktMgr;"
'strSQL = "SELECT NotifyMapping.MktMgr, NotifyMapping.MktMgrEmail, zipcode.City, zipcode.State zipcode.Zip FROM NotifyMapping, zipcode WHERE NotifyMapping.MktID=zipcode.MktID"
'& "WHERE last_name LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
'& "OR first_name LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
'& "ORDER BY last_name;"

' Execute our query using the connection object. It automatically
' creates and returns a recordset which we store in our variable.
Set rstSearch = cnnSearch.Execute(strSQL)

' Display a table of the data in the recordset. We loop through the
' recordset displaying the fields from the table and using MoveNext
' to increment to the next record. We stop when we reach EOF.
' For fun I'm combining some fields and showwing you can do more then
' just spit out the data in the form it is in in the table.
%>
<table border="0">
<tr>
<th>Name</th>
<th>&nbsp;</th>
<th>Email</th>
<th>&nbsp;</th>
<th>Location</th>
</tr>

<%
Do While Not rstSearch.EOF

%>
<tr>
<td>
<a href="details.asp?cd=<%=rstSearch("ID")%>">
<%= rstSearch.Fields("MktMgr").Value %></a></td>
<td>&nbsp;</td>
<td><%= rstSearch.Fields("MktMgrEmail").Value %></td>
<td>&nbsp;</td>
<td>
&nbsp;&nbsp;<%= rstSearch.Fields("City").Value %>
&nbsp;&nbsp;<%= rstSearch.Fields("State").Value %>
&nbsp;&nbsp;<%= rstSearch.Fields("Zip").Value %></td>
</tr>
<%
rstSearch.MoveNext
Loop
%>
</table>
<%
' Close our recordset and connection and dispose of the objects
rstSearch.Close
Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing


End If


%>

ProWeb
01-18-2006, 06:28 AM
put in an if after the Set statement.
i.e.
<% IF rstSearch.eof THEN
Response.write("No Records Found")
ELSE
For loop
Display data
next
END IF
%>

Or
If rstSearch.EOF then Response.End ---- to stop processing