Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi. This is my procedure

SQL
create proc temp @value nvarchar(max)
as
begin
    DECLARE @sql nvarchar(max)
    set @sql = N'Select * from dbo.Categories
    where CategoryName in (' + @value +')';
    print @sql
exec sp_executesql @sql

end



I can pass multiple value for @value like this and it works

SQL
temp @value = '''Beverages'',''Condiments'''


In my window form, I have multiple check boxes, for example if checkbox 1 & 2 were check:

C#
value = "'''"+cb1.Text + "'',''" +cb2.Text + "'''" 


and pass it through SQL parameter, but it doesn't work.It doesn't throw any exception but doesn't return anything either.

Any help was appreciated.
Posted

I think you are putting in extra apostophe's on the left of your first parameter and the right of your last parameter.

Fix that and things should work.
 
Share this answer
 
Thanks for replying but I don't think so because it works fine in SQL. I just don't figure out why it doesn't work on my winform
 
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