Search SQL Database

Posted on 2005-04-05
Medium Priority
Last Modified: 2010-04-25
Hi Everyone

I have 3 combo boxes within a Form, a user can select an option from any number of these combo boxes, (e.g they can select the first one and the second one, only the first one, all 3 or the 2nd and 3rd one etc).

How do I code this in ASP vbscriptso that the database will display results based on these search parameters. I can easily do if the user had to select an option from all 3 but I don't know how to do it if the user selects 1-2 boxes.

Using sql server and asp vb

Any help would be great



Question by:patelajk

Accepted Solution

alexhogan earned 252 total points
ID: 13708817
You will probably want to use a "Select Case" statement.

If you set the "Select Case" to "True", then you can set each case as a parameter of either 1,2 or 3.  Where the first case is a query with one drop down selection.  The second case has two drop down selections and the third, three.

When the form is processed you can loop through the post data to see how many drop downs were used based on the object names.
LVL 55

Assisted Solution

by:Ryan Chong
Ryan Chong earned 248 total points
ID: 13709590
The tricks will be always make the 1st item's value in drop down with empty value, and then when the user submit the form, we'll check the request object for the drop-down menus, if the request object for the a drop down is not empty, we then add the selected value as a part of our query statement. Basically, 3 "IF" statements are using to construct the sql statement that will display the results later...

Get the idea? Anyway, you can always post your currently scripts available, so that we can try to justify it for you, regards
LVL 20

Expert Comment

ID: 13710573
I believe this would be aswered better in the ASP.NET section, you could have it reposted there.. :o)

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question