troubleshooting Question

Getting a list of values into SQL Sproc via one parameter (ie. WHERE name IN( @param ) (where param is a comma delimited list of vals)

Avatar of EllsworthAdhesives
EllsworthAdhesives asked on
Microsoft SQL ServerC#ASP.NET
6 Comments1 Solution512 ViewsLast Modified:
I ran into an issue with the ELB: multi-select list box (thrid part control for ASP.NET which allows for multiple dropdown selections). I have an ELB multi-selectable dropdown, and I want to send selected contents (ie. “Someone, SomeoneElse, ThirdPerson” , etc. as a varchar (say: “@ELB_vals”) parameter to a SQL stored proc that is constructed as follows (simplified for brevity):

SELECT * FROM tblUsers WHERE UserName IN(@ELB_vals)

I thought this would work, but for whatever reason, while sending a single value works, sending the delimited list will not work. I tried replacing all of the commas with ‘,’ which I thought MSSQL would approve of, but no. Does anyone know how I can format the selected values string into something that my sproc will take?  (ie. I want the parameter to be 'Someone', 'SomeoneElse', 'ThirdPerson'----> as I said I tried doing this with Replace, however ASP.NET leaves the surrounding double quotes, making it "'Someone', 'SomeoneElse', 'ThirdPerson'", which causes the thing to fail.


Thanks for any help/suggestion in advance,


Colin
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros