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

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


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

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

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

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.

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