473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Sql query and drop down list

Hi all,

I have 2 dropdownlists that after selection feed the WHERE in a sql
query

SELECT * FROM tbl WHERE a = 'dropdown1' AND b = 'dropdown2'

I also want to add the selection to the dropdownlist that everything of
a and/or b is selected.

Is there some sort of character that I can put between the '' so it
selects everything?

Regards
Stijn

Sep 4 '06 #1
3 2985
A couple of suggestions:

1. Don't include the where clause if the user selects "everything" for a
and/or b.

2. Instead of using WHERE a = 'dropdown1' use like 'dropdown1' instead. If
they select "everything" use WHERE a like '%' to select everything.

<ta******@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
Hi all,

I have 2 dropdownlists that after selection feed the WHERE in a sql
query

SELECT * FROM tbl WHERE a = 'dropdown1' AND b = 'dropdown2'

I also want to add the selection to the dropdownlist that everything of
a and/or b is selected.

Is there some sort of character that I can put between the '' so it
selects everything?

Regards
Stijn

Sep 4 '06 #2
Thanks for the reply.

The % works but only partly. I have a gridview that is populated with
data according to selections made with the 2 dropdownlists. One of the
variable needs to be a varchar, no problem there. The other is an int.
Since % is a string I get an exception. Someone knows how I can work
around this without changing my database.

Regards,
Stijn
PaulR schreef:
A couple of suggestions:

1. Don't include the where clause if the user selects "everything" for a
and/or b.

2. Instead of using WHERE a = 'dropdown1' use like 'dropdown1' instead. If
they select "everything" use WHERE a like '%' to select everything.

<ta******@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
Hi all,

I have 2 dropdownlists that after selection feed the WHERE in a sql
query

SELECT * FROM tbl WHERE a = 'dropdown1' AND b = 'dropdown2'

I also want to add the selection to the dropdownlist that everything of
a and/or b is selected.

Is there some sort of character that I can put between the '' so it
selects everything?

Regards
Stijn
Sep 4 '06 #3
I personally would use option 1 I described below. And I would have the
logic to build the query in a stored procedure in the database. Allowing
SELECT access from your application is bad practice, especially if you have
not protected against SQL injection.

<ta******@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
Thanks for the reply.

The % works but only partly. I have a gridview that is populated with
data according to selections made with the 2 dropdownlists. One of the
variable needs to be a varchar, no problem there. The other is an int.
Since % is a string I get an exception. Someone knows how I can work
around this without changing my database.

Regards,
Stijn
PaulR schreef:
>A couple of suggestions:

1. Don't include the where clause if the user selects "everything" for a
and/or b.

2. Instead of using WHERE a = 'dropdown1' use like 'dropdown1' instead.
If
they select "everything" use WHERE a like '%' to select everything.

<ta******@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegr oups.com...
Hi all,

I have 2 dropdownlists that after selection feed the WHERE in a sql
query

SELECT * FROM tbl WHERE a = 'dropdown1' AND b = 'dropdown2'

I also want to add the selection to the dropdownlist that everything of
a and/or b is selected.

Is there some sort of character that I can put between the '' so it
selects everything?

Regards
Stijn

Sep 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Don Wash | last post by:
Hi There! I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to widen the Drop down box's Pull-Down list's width? I'm not talking about the Drop-down box's width but the box...
2
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will...
1
by: pmelanso | last post by:
Hello, I have a drop down list which is dynatically loaded from a database and I have a second drop down list that is also dynatically loaded depending on what is selected in the first drop down...
0
by: dokidoki | last post by:
i have 1 drop down list that i bind to a database. Now the problem is when to come edit / update module, i will fetch a result from database. then i want the drop down list to show the exact result...
1
by: accyboy1981 | last post by:
Hi, I new to C# so please forgive me if this is simple. I've got 2 drop down lists the first is hard coded with data where as the second is populated from a database. The options that appear in...
8
by: Ed Dror | last post by:
Hi there ASP.NET 2.0 VB & SQL Express Lest take Northwind Categories Products as example I create a table that hold these two together and I create a stored procedure like select ProductID,...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
3
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the...
3
by: =?Utf-8?B?bXNjZXJ0aWZpZWQ=?= | last post by:
Has anyone successfully used an Access query from .NET? I am trying to do this and am getting a weird error. .NET calls queries 'stored procedures'. The error I am getting says "Schema could not be...
1
by: goldstar | last post by:
Hello All, Just got a quick query, I have an order form, if an item is selected from the ItemID drop down list. this would display within a listbox, and then another item could be ordered. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.