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
C#ASP.NETMicrosoft SQL Server
6 Comments2 Solutions512 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
ASKER CERTIFIED SOLUTION
Nightman
CTO

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 2 Answers and 6 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 2 Answers and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004