ASP.NET TableAdapter Parameters IN Query

I'm using a TableAdapter and the query looks similar to the following:

SELECT * FROM Table WHERE Type In (@type)

From my ASP.NET page, the type can either be All, A, B, or C (All should incorporate A, B, & C).  The query works with a single parameter (meaning A, B or C) but when I select the "All" option the query doesn't return any rows.  

Does anyone have any suggestions on how to query the table using a drop down list with the values "All", A, B, or C?
LVL 1
mmeiselAsked:
Who is Participating?
 
spprivateCommented:
Currently when you select All the query will become
SELECT * FROM Table WHERE Type In ('All') which will return none.
You have to somehow manipulate the code where you set the parameter to like this.
Where you set the value for @ type
put a conditon
if(ddl.selectedvalue='All')
{
param  = 'A,B,C')
}
Now this is a crude way of doing it.The efficient and neat way is to do it in stored procedure and check in sp if you want to pull specific value or all values
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.