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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help creating a table search

Status
Not open for further replies.

Tifa

Programmer
Oct 13, 2002
10
0
0
US
I am trying to create a table search where when you type in a person's last name, the form will search the table and display the listings with the matching last name. However, I can't get it to display the results. Here is my ASP:

<body>
<% FindName = Request.Form(&quot;LastName&quot;) %>

<p align=&quot;center&quot;><b>Database Search</b></p>
<form method=&quot;POST&quot; name=&quot;search&quot; action=&quot;database.asp&quot;>

<p align=&quot;center&quot;>
<b>Last name :</b>
<input type=&quot;text&quot; name=&quot;Name&quot; size=&quot;20&quot;><input type=&quot;submit&quot; value=&quot;Find&quot; name=&quot;B1&quot;></p>
</form>

<%
Set CNObj=Server.CreateObject(&quot;ADODB.Connection&quot;)
CNObj.Open &quot;DBQ=e:\ajord461\4280\contacts.mdb;DRIVER=Microsoft Access Driver (*.mdb)&quot;
Set RSObj=Server.CreateObject(&quot;ADODB.Recordset&quot;)
SQLString = &quot;SELECT * FROM Personal WHERE LastName = '&quot; & FindName & &quot;'&quot;
RSObj.Open SQLString,CNObj


Do While Not RSObj.EOF %>

<table>
<tr>
<td><%=RSObj.Fields(&quot;LastName&quot;)%></td>
<td><%=RSObj.Fields(&quot;FirstName&quot;)%></td>
<td><%=RSObj.Fields(&quot;MiddleName&quot;)%></td>
<td><a href=&quot;mailto:<%=RSObj.Fields(&quot;Email&quot;)%>&quot;>
<%=RSObj.Fields(&quot;Email&quot;)%></a></td></tr>

<% RSObj.MoveNext
Loop

RSObj.Close
CNobj.Close
%>

</table>

</body>

It is searching the table but not displaying the results. Anyone know what could be wrong? Thanks for the help!
 
I think to display the values you either need to add &quot;.value&quot;

<%=RSObj.Fields(&quot;LastName&quot;).value%>

or remove &quot;.Fields&quot;

<%=RSObj(&quot;LastName&quot;)%>
 
Try modifying your SELECT statement into something like:
Code:
SELECT * FROM Personal WHERE Trim(LastName) = '&quot; & Trim(FindName) & &quot;'&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top