Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created a data table with a description and three checkboxes which represent selection areas..

The datatable is bound to a grid which..
the user can then place a check in the box of one of the three areas that the description fits in..

Once the user has completed the checking, I need to include that into a SQL criteria to select records based on the outcome of their selections of description..

Eg...
Description Demand(Checkbox1) Maintenance(CheckBox2) Warranty(Checkbox3)


Red yes(Checkbox1)
Blue yes(Checkbox1)
Green yes(Checkbox2)
Yellow yes(Checkbox3)


now I want to select records from another file where the description is in one of the checkbox selections

other file

Description Date Value
Red 01/01/2010 $30
Blue 02/02/2010 $45
Red 03/01/2010 $10
Green 04/02/2010 $20
Yellow 05/02/2010 $15
Green 06/01/2010 $22


Output for Demand(Checkbox1)
Red 01/01/2010 $30
Blue 02/02/2010 $45
Red 03/01/2010 $10

Output for Maintenance
Green 04/02/2010 $20
Green 06/01/2010 $22

Output for Warranty
Yellow 05/02/2010 $15

I need the SQL Statement or Statements that will allow me to create the "in" clause or the "Exists" statments..of an SQL Statment..


Thanks

Scott
Posted
Updated 19-Aug-10 0:35am
v2
Comments
Toli Cuturicu 19-Aug-10 5:42am    
Reason for my vote of 1
Just statements; no question.
R. Giskard Reventlov 19-Aug-10 6:37am    
What have you already tried? How did that work out? What specific issue arose that you need help with?
sadderson 19-Aug-10 12:36pm    
I need to do this but haven't tried anything because I don't know how to include the result of the grid in another select statement..

I need the users input to find out what categories the descriptions are in ... but I don't know how to get that into a sql query...

Thanks

Scott

1 solution

I know this article refers to ASP.Net, but you may find it handy: How To Loop Through And Examine Checkbox Controls In A Datagrid[^].
You should be able to find equivalent functions in the Windows Forms version of the controls. Using the results, you should be able to construct a SQL command to fetch the data specified by the user.
 
Share this answer
 

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