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

I need Help Pls.

Status
Not open for further replies.

joelxez

Programmer
Apr 18, 2002
67
PH
Dear Experts,

I have ASP search below but it displays all the Recordset. Pls help me to Edit the Code....

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<head>

<title>Search ASP</title>
</head>
<body>
<% Set MyConn=Server.CreateObject(&quot;ADODB.Connection&quot;)
MyConn.Open &quot;PROVIDER=Microsoft.Jet.OLEDB.4.0;&quot; & _
&quot;DATA SOURCE=&quot; & server.mappath(&quot;personal.mdb&quot;)
MySQL=&quot;Select * from tblper Where Name Like '%&quot; & txtfind & &quot;%' Order by Name&quot;
Set MyRs=MyConn.Execute(MySQL)
%>
<table border=&quot;1&quot;>
<tr bgcolor=&quot;&quot;><% 'Put Headings On The Table of Field Names
howmanyfields=MyRs.fields.count -1 %>
<% for i=0 to howmanyfields %>
<td><b><font color=&quot;&quot;><%=MyRs(i).name %></font> </b></td>
<% next %>
</tr>
<% ' Get all the records
do while not MyRs.eof %>
<tr bgcolor=&quot;&quot;>
<% for i = 0 to howmanyfields
ThisRecord = MyRs(I)
If IsNull(ThisRecord) Then
ThisRecord = &quot; &quot;
end if %>
<td valign=top><font color=&quot;&quot;><%=Thisrecord%></font></td><% next %>
</tr>
<%MyRs.movenext
loop%>
</table>

<%
MyRs.close
Set MyRs= Nothing
MyConn.Close
set MyConn=nothing
%>

</body>
</html>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

here is my HTML form

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<html>

<head>
<title>Search HTML</title>
</head>

<body>
<form method=&quot;GET&quot; action=&quot;find.asp&quot;>

<p><input type=&quot;text&quot; name=&quot;txtfind&quot; size=&quot;18&quot;>
<input type=&quot;submit&quot; value=&quot;Find&quot; name=&quot;B1&quot;></p>
</form>

</body>

</html>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Joel,

 
Hi Joel,
do you set your txtFind anywhere before searching the db?!
try inserting this:
Code:
txtFind = request.querystring(&quot;txtfind&quot;)
between
Code:
<body>
and
Code:
<% Set MyConn=Server.CreateObject(&quot;ADODB.Connection&quot;)

I guess what happens is that you end up with a sql-query with nothing between the percent-signs, which would explain why it matches all records... This is not a bug - it's an undocumented feature...
;-)
 
jonax,

that is it, thank you very much.

joel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top