kasim
06-19-2003, 06:06 AM
Hi All. I am creating a website linked to a database. Functionality is adding, deleting, viewing, searching but for weeks now I have become stuck on the search page. I have completed add, and display that fully work. The search function consists of 2 pages. One is a html document and the other ASP. In the html document the user specifies the search criteria and then the ASP page is supposed to do the search which isn’t working much to my frustration! Please Please Please cam someone help me with this code. Many Thanks!
search.htm
<title>Search Log</title>
<form action="searchsubmit.asp" method="POST">
<select name="txtField">
<option value="Analyst_Name">Analyst Name</option>
<option value="Task_No">Task No</option>
</select>
<input type="Text" name="txtSearch" size="20"><p>
<input type="Submit" name="Submit" value="Search">
</form>
searchsubmit.asp
<%@ Language="VBScript"%>
<% Option Explicit %>
<!-- #include file='DBConnection.asp'-->
<%
dim rs
dim con
dim sql
Set con = GetADOConnection()
sql = "SELECT * FROM ServReqLog Where " & request.form("txtField") & " LIKE '%%" & request.form("txtSearch") & "%%';"
set rs = con.Execute(sql)
%>
<HTML>
<HEAD>
<TITLE>Search Results</TITLE>
</HEAD>
<BODY>
<font size="3" face="Arial">Search Results</font><hr>
<%
do while NOT rs.EOF
%>
<% If request.form("txtField")="Analyst_Name" then response.write rs("AnalystName") & "<br>"%>
<% If request.form("txtField")="Task_No" then response.write rs("TaskNo") & "<br>"%>
<hr width="200" align="left">
<%
CurrentRecordset.Movenext
loop
%>
</BODY>
</HTML>
search.htm
<title>Search Log</title>
<form action="searchsubmit.asp" method="POST">
<select name="txtField">
<option value="Analyst_Name">Analyst Name</option>
<option value="Task_No">Task No</option>
</select>
<input type="Text" name="txtSearch" size="20"><p>
<input type="Submit" name="Submit" value="Search">
</form>
searchsubmit.asp
<%@ Language="VBScript"%>
<% Option Explicit %>
<!-- #include file='DBConnection.asp'-->
<%
dim rs
dim con
dim sql
Set con = GetADOConnection()
sql = "SELECT * FROM ServReqLog Where " & request.form("txtField") & " LIKE '%%" & request.form("txtSearch") & "%%';"
set rs = con.Execute(sql)
%>
<HTML>
<HEAD>
<TITLE>Search Results</TITLE>
</HEAD>
<BODY>
<font size="3" face="Arial">Search Results</font><hr>
<%
do while NOT rs.EOF
%>
<% If request.form("txtField")="Analyst_Name" then response.write rs("AnalystName") & "<br>"%>
<% If request.form("txtField")="Task_No" then response.write rs("TaskNo") & "<br>"%>
<hr width="200" align="left">
<%
CurrentRecordset.Movenext
loop
%>
</BODY>
</HTML>