Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Scenario: I have a checkedlistbox with the following food items: rice, meat, bananas. Lets assume all three items have been checked. Is it possible to retrieve the ids of these checked items from database in a single select statement and the checked items as dbparameter values for select statement.

[edit]Subject only - OriginalGriff[/edit]
Posted
Updated 5-Jul-11 22:17pm
v2

1 solution

Assuming you have a variable number of parameters (i.e. there may be more than just the three!) then the short answer is that it is possble and there are a number of ways to do it.

you COULD concatenate the string descriptions into a single comma separated string, pass that as a parameter and pass it to a stored procedure that returns a table with one row per Id

you COULD use a user-defined type in SQL Server, populate it in your application and pass it as a single parameter to a stored procedure, and again return the Ids

however, I wonder where you got the string s from - aren't they from teh database originally? if so, then when you retrieve the strings, retrieve their Ids too,and store them in your application, so no need to go retrieve them later
 
Share this answer
 
Comments
capdevillia 6-Jul-11 4:41am    
Hmm! Let me try that out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900