Many easy ways to solve this

1) Dynamic SQL (which I'd personally avoid)
2) Pass in a parameter of type XML;

var searchParams = "<SearchFields>
   <Field>MyValue1</Field>
   <Field>MyValue2</Field>
</SearchFields>"

Then in your SQL query (assuming your SQLParameter is type XML and is called
@SearchParams



SELECT
    field1,
    field2
FROM
    table
WHERE
    @SearchParams.exist('SearchFields/Field[text() = sql:column("field3")]')
= 1)

On Mon, Dec 6, 2010 at 3:27 PM, Suraj <[email protected]> wrote:

>
>
> Hi,
>
> I have two list boxes Listbox1 and Listbox2. Based on the item selected in
> Listbox1, results are displayed in Listbox2. After this, user can select one
> or more items from Listbox2 and click on Search button.
>
> I am trying to get results using a SQL query which takes the items selected
> in Listbox2 and returns the results. This is working even though the user
> selects multiple items from Listbox2.
>
> The SQL query is in code behind. I am planning to move the query in code
> behind to the Data access layer.
>
> I wrote a stored procedure which takes input of Listbox1’s item and
> Listbox2’s item but this failed as we can select multiple items from
> Listbox2.
>
> How can I achieve this?
>
>
>
> --
> Regards,
> Suraj
>
>

Reply via email to