ASP.NET TableAdapter Parameters IN Query

Posted on 2009-04-20
Last Modified: 2012-08-14
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?
Question by:mmeisel
    1 Comment
    LVL 15

    Accepted Solution

    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
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now