none
Query with variable number of parameters RRS feed

  • Question

  • Hello.
    Let's say I have a basic search form, with several filter fields. The user will fill just some of them, then press search button.
    Then I have to produce a query with only the filters filled by the user.
    Is there a way to do it other than by hand?
    With Visual Studio Dataset Designer I can define query with parameters, and it will produce automatically the necessary code, but it doesn't allow me to produce a query with a variable number of parameters.
    Of course i can procude the SqlCommand by hand, adding parameters that I need one by one. But if there are many filter fields in the form this can be really time consuming.
    Any idea?
    Thanks
    Thursday, May 8, 2008 9:42 AM

Answers

  • You could just create a single query which handles optional parameters. See the following:

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=97317



    Thursday, May 8, 2008 12:33 PM