Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
ok........
in window form i have three different-2 criteria to filter data for thre i have three cheakesdlistbox(1st for partyname .2nd for exchange type and 3rd one for itemname) each contain number of items let if user select(by cheeking cheak box) 10 party name now he select 2 exhange type of the available exchange type and in third ithemname may he select all item or sum now as he press show button data should be fill in datagridview with the above selection .........now i want to pass these selected values in whare clause ..like..whrere partyanme="all value from partyname" and exchangetype="all selected exhange type"and itemname="selected itemname"....
please help me how to write selct query with multiple selected values....

C#.sqlserver

thanks in advanced



lakhan
Posted

1 solution

Your query must look like this:
SQL
CREATE PROCEDURE spGetDetails
@exchangetype varchar(50),
@partyname varchar(50),
@itemname varchar(50)
BEGIN

SELECT * FROM [tablename] WHERE exchangetype = @exchangetype
                          AND partyname=@partyname
                          AND itemname=@itemname

END

You need to pass the values from C# as parameters to your SQL Stored Proc.

Regards,
Eduard
 
Share this answer
 
Comments
[no name] 8-Dec-11 5:42am    
if u dont mind can u describe how ?????????
[no name] 8-Dec-11 21:29pm    
you need to study ADO.NET and Stored Procedure.

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