Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
creating a search on either of two fields
Old 05-21-2006, 01:55 PM creating a search on either of two fields
redgeordieboy99's Avatar
Skilled Talker

Posts: 61
Trades: 0
i have created a site using dreamweaver mx 2004 and ms-access. i have created a search facility which searches for a product based on two fields. What i would like to do is a search based on either or both of the two fields.
redgeordieboy99 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-21-2006, 02:03 PM Re: creating a search on either of two fields
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
WHERE field1 = criteria OR field2 = criteria
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-21-2006, 02:59 PM Re: creating a search on either of two fields
redgeordieboy99's Avatar
Skilled Talker

Posts: 61
Trades: 0
This is the code from the search results page, it doesnt return any results

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/Petwise.asp" -->
<%
Dim rsResults__MMColParam
rsResults__MMColParam = "1"
If (Request.Form("ysBrand") <> "") Then
rsResults__MMColParam = Request.Form("ysBrand")
End If
%>
<%
Dim rsResults__ysCat
rsResults__ysCat = "1"
If (Request.Form("ysCategory") <> "") Then
rsResults__ysCat = Request.Form("ysCategory")
End If
%>
<%
Dim rsResults
Dim rsResults_numRows

Set rsResults = Server.CreateObject("ADODB.Recordset")
rsResults.ActiveConnection = MM_Petwise_STRING
rsResults.Source = "SELECT * FROM Product WHERE Brand = '" + Replace(rsResults__MMColParam, "'", "''") + "' OR Category = '" + Replace(rsResults__ysCat, "'", "''") + "'"
rsResults.CursorType = 0
rsResults.CursorLocation = 2
rsResults.LockType = 1
rsResults.Open()

rsResults_numRows = 0
%>

Last edited by redgeordieboy99; 05-21-2006 at 03:07 PM..
redgeordieboy99 is offline
Reply With Quote
View Public Profile
 
Old 05-21-2006, 03:54 PM Re: creating a search on either of two fields
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
what does the query look like when built ?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-21-2006, 07:28 PM Re: creating a search on either of two fields
redgeordieboy99's Avatar
Skilled Talker

Posts: 61
Trades: 0
this is the query


Last edited by redgeordieboy99; 05-21-2006 at 07:35 PM..
redgeordieboy99 is offline
Reply With Quote
View Public Profile
 
Old 05-21-2006, 08:18 PM Re: creating a search on either of two fields
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
yes very nice, could we now see the SQL code AFTER your form has been submitted and the query has been built.

it's the value of the variables that is sent to the query that is important NOT the construction.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-21-2006, 08:25 PM Re: creating a search on either of two fields
redgeordieboy99's Avatar
Skilled Talker

Posts: 61
Trades: 0
i hope this is the correct piece of code- excuse my ignorance

<td colspan="2">Product: <span class="TextMain"><%=(rsProdDetails.Fields.Item("Pr odName").Value)%></span></td>
<td width="200" rowspan="3" align="center" valign="middle"><img src="<%=(rsProdDetails.Fields.Item("Picture").Valu e)%>"></td>
</tr>
<tr class="TextAdminBold">
<td width="221">Brand: <span class="TextMain"><%=(rsProdDetails.Fields.Item("Br and").Value)%></span></td>
<td width="203">Category: <span class="TextMain"><%=(rsProdDetails.Fields.Item("Ca tegory").Value)%></span></td>
</tr>
<tr class="TextAdminBold">
<td colspan="2">Price &pound;<span class="TextMain"><%= FormatNumber((rsProdDetails.Fields.Item("Price").V alue), 2, -2, -2, -2) %></span></td>
</tr>
<tr class="TextAdminBold">
<td colspan="3">Description: <span class="TextMain"><%=(rsProdDetails.Fields.Item("De scription").Value)%></span></td>
</tr>
</table>
<p align="center"><a href="javascript:history.go(-1)" class="TextBold">&lt;&lt; Back</a></p>
<p>&nbsp;</p></td>
</tr>
</table>
redgeordieboy99 is offline
Reply With Quote
View Public Profile
 
Old 05-22-2006, 03:45 AM Re: creating a search on either of two fields
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Nope I need you to response.write out the value of rsResults.source and paste the actual text that appears in the browser.

It's debugging101 "Print out the bits that are going wrong so you can see why they are wrong"
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to creating a search on either of two fields
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26129 seconds with 12 queries