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> </th>
<th>Email</th>
<th> </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> </td>
<td><%= rstSearch.Fields("MktMgrEmail").Value %></td>
<td> </td>
<td>
<%= rstSearch.Fields("City").Value %>
<%= rstSearch.Fields("State").Value %>
<%= 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
%>
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> </th>
<th>Email</th>
<th> </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> </td>
<td><%= rstSearch.Fields("MktMgrEmail").Value %></td>
<td> </td>
<td>
<%= rstSearch.Fields("City").Value %>
<%= rstSearch.Fields("State").Value %>
<%= 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
%>