Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · ASP.NET Newsletter Application · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : ASP : ASP 3.0 : Search form Signup · Login
Author Thread
Search form
Posted in tutorial: An ASP Tutorial to create your own Database driven Search Engine
·  closemofo
User
Joined: 7 Jul 2004
Total Posts: 1

Search form

Posted: 28 Sep 2004
How to have the search form and the answers in the same window.
I want to use only one page.
Thanks
·  drephius
User
Joined: 28 Oct 2004
Total Posts: 1
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.
Want to leave a comment? Login or Register for free!

Users Who Have Visited This Thread In Last 24 Hours
6 Visitors

Login to post a comment or start a new thread
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2010 Stardeveloper.com, All Rights Reserved.