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

database search-a newbie question

Status
Not open for further replies.

leca07

Technical User
Dec 22, 2001
20
0
0
YU
Hi everyone...
Since I'm a complete ASP newbie I'd really really really appreciate your help. I have to make a simple

database search based on Access' .mdb-file. I've found some code samples but they all list search

results on the same page, bellow SEARCH button and I want them listed on a blank page. I'm posting

you my html code and database's name is products.mdb. If anyone of you have a time to add ASP

code please do so or at least point me to a site where I can get the code. Thanx in advance.
Jane

<html>
<head>
<title>Product Search</title>
</head>
<body >
<table width=&quot;780&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr><td> <form name=&quot;form1&quot; method=&quot;get&quot; action=&quot;&quot;>
key word <input type=&quot;text&quot; name=&quot;textfield&quot;>
product <input type=&quot;text&quot; name=&quot;textfield2&quot;>
manufactor <input type=&quot;text&quot; name=&quot;textfield3&quot;>
price range <select name=&quot;select&quot;>
<option selected>$1-50</option>
<option>$50-100</option>
<option>$100-200</option></select></form></td></tr>
<tr><td><input type=&quot;submit&quot; name=&quot;Search&quot; value=&quot;Search&quot;></td></tr>
</table>
</body>
</html>
 
page1.asp
<html>
<head>
<title>Product Search</title>
</head>
<body >
<table width=&quot;780&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr><td> <form name=&quot;form1&quot; method=&quot;get&quot; action=&quot;page2.asp&quot;>
key word <input type=&quot;text&quot; name=&quot;textfield&quot;>
product <input type=&quot;text&quot; name=&quot;textfield2&quot;>
manufactor <input type=&quot;text&quot; name=&quot;textfield3&quot;>
price range <select name=&quot;priceSelect&quot;>
<option selected value=1>$1-50</option>
<option value=2>>$50-100</option>
<option value=3>>$100-200</option></select></form></td></tr>
<tr><td><input type=&quot;submit&quot; name=&quot;Search&quot; value=&quot;Search&quot;></td></tr>
</table>
</body>
</html>


page2.asp

<%
Dim Conn, dbpath
Set Conn = Server.Createobject(&quot;ADODB.Connection&quot;)
Dbpath =&quot;DBQ=&quot; & server.mappath(&quot;/databases/mydb.mdb&quot;)
Conn.open &quot;DRIVER={Microsoft Access Driver (*.mdb)}; &quot; & dbpath
set objrs = server.createobject(&quot;ADODB.recordset&quot;)

strSQL = &quot;SELECT field1, field2, field3, price FROM myTable WHERE price &quot;
select case request(&quot;priceSelect&quot;)
case &quot;1&quot;
strsql = strsql & &quot;BETWEEN 1 AND 50 &quot;
case &quot;2&quot;
strsql = strsql & &quot;BETWEEN 50 AND 100 &quot;
case &quot;3&quot;
strsql = strsql & &quot;> 100 &quot;
if trim(request(&quot;textfield&quot;)) <> &quot;&quot; then strSQL = strSQL & &quot;AND field1 LIKE '*&quot; & trim(request(&quot;textfield&quot;)) & &quot;*' &quot;
if trim(request(&quot;textfield2&quot;)) <> &quot;&quot; then strSQL = strSQL & &quot;AND field2 LIKE '*&quot; & trim(request(&quot;textfield2&quot;)) & &quot;*' &quot;
if trim(request(&quot;textfield3&quot;)) <> &quot;&quot; then strSQL = strSQL & &quot;AND field3 LIKE '*&quot; & trim(request(&quot;textfield3&quot;)) & &quot;*' &quot;

set objRS = conn.execute(strsql)

if not objrs.eof then
strHTML = &quot;<table border=1>&quot;
do while not objRS.EOF
strHTML = strHTML &_
&quot;<tr>&quot;&_
&quot;<td>&quot; & objrs(&quot;field1&quot;) & &quot;</td>&quot; &_
&quot;<td>&quot; & objrs(&quot;field2&quot;) & &quot;</td>&quot; &_
&quot;<td>&quot; & objrs(&quot;field3&quot;) & &quot;</td>&quot; &_
&quot;<td>&quot; & objrs(&quot;price&quot;) & &quot;</td>&quot; &_
&quot;</tr>&quot;
objrs.movenext
loop
strHTML = strHTML & &quot;</table>&quot;
else
strHTML = &quot;No Records Found&quot;
end if

response.write strHTML
%> -----------------------------------------------------------------
&quot;The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.&quot;
- unknown

mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top