|
Search Form Posted: 28 Oct 2004
Step1: Create an form on a html page with text fields that will receive the input of what you want to search. <body> <form method="POST" name="frmsearch" action="searchresults.asp"> <p> <input type="text" name="txtsearch" size="20"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> </form>
</body> Step2: Create an ASP page to process the results of the search. On the top of the page insert- <%@Language=VBScript%>
In the body declare your varibles and put in the db info <% Dim db Dim cn Dim rs Dim strSql Dim searchstring searchstring = Request.Form("txtsearch")
db = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("yourdatabase.mdb") & ";Persist Security Info=False" set cn = Server.CreateObject("ADODB.Connection") set rs = server.CreateObject("adodb.recordset") cn.open db sqlstr = "select * from tablename WHERE searchstring LIKE '" & fieldname & "%'" rs.open sqlstr,cn,1,2 if not rs.eof then rs.movefirst do until rs.eof response.write "rs("fieldname")" & " <BR>" rs.movenext Loop rs.close cn.close else%>
Give that a try.
|