ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 19th, 2003, 05:17 AM
Etaks01 Etaks01 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 Etaks01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Multiple searchfields in my result page(ASP vbScript Dreamweaver)

Hi there,

I'm trying to do a search on my database through multiple search fields i've tried to use 'AND' in my sql but then there are no results. When i search for one value through one inputfield everything works oke but when i add an input field on my search page for a combined search nothing works!!. could someboby help me?!


Thanx,

Reply With Quote
  #2  
Old August 19th, 2003, 06:23 AM
Etaks01 Etaks01 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 Etaks01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I figured out how to search multiple fields but when i leave the first field blank then the search doesn't work any more. I've tried to change the 'And' into 'Or" but then the entire database is shown.!!

Reply With Quote
  #3  
Old August 19th, 2003, 06:37 AM
Etaks01 Etaks01 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 Etaks01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
by the way this is the code:

SELECT Vissoort, Plaats, vanglocatie, Aas
FROM Beettabel
WHERE Vissoort like 'MMColParam' AND Plaats like 'MMColPlaats' AND Aas like 'MMColAas' AND Weer like 'MMColWeer'

Reply With Quote
  #4  
Old August 19th, 2003, 08:14 AM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 4 m 10 sec
Reputation Power: 75
Well, the problem is because if you leave a field blank in your search, all your AND statements make the search look for only fields that match all the other search terms, and have a blank field, which apparently doesn't exist. (Maybe because all your database entries have all fields full.) When you use OR, it finds all entries that match any one of the search terms, which apparently is the whole database.

You could avoid this by using some logic before your search, to see if any fields are empty, and either prompting the user to fill in a value for that field, or running the search without that parameter. I don't have an elegant way to do this, but if you need more help, I can post something that should at least function.
HTH

Reply With Quote
  #5  
Old August 19th, 2003, 08:25 AM
Etaks01 Etaks01 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 4 Etaks01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, but i think there is an other problem because when i only fill in the first field and i leave the rest of the fields empty(although they are full in the database) i do get resultes on the first field! i could be wrong thou.

Reply With Quote
  #6  
Old August 19th, 2003, 08:49 AM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 4 m 10 sec
Reputation Power: 75
Not knowing more about your database set up, I'm not really sure why you are getting the results you are. However, if the results you get are correct unless the first field is blank, try (untested)
Code:
If request.form("MMColParam")="" Then
   my_sql = "SELECT Vissoort, Plaats, vanglocatie, Aas 
FROM Beettabel 
WHERE Plaats like 'MMColPlaats' AND Aas like 'MMColAas' AND Weer like 'MMColWeer'"

Else
   my_sql = "SELECT Vissoort, Plaats, vanglocatie, Aas 
FROM Beettabel 
WHERE Vissoort like 'MMColParam' AND Plaats like 'MMColPlaats' AND Aas like 'MMColAas' AND Weer like 'MMColWeer'"

I haven't tried this, and I'm not sure the quotes are escaped correctly, but you get the idea, I hope.
If the query works as long as the first field isn't blank, then check, and if the first field is in fact blank, don't use it in the query.

edit: bah, stupid code spacing. Sorry, thats pretty ugly.
__________________
--Dave--

U2kgSG9jIExlZ2VyZSBTY2lzLCBOaW1pdW0gRXJ1ZGl0aW9uaXMgSGFiZXM=

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Multiple searchfields in my result page(ASP vbScript Dreamweaver)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway