Quantcast
Viewing all articles
Browse latest Browse all 27101

List in select clause

I have a List(Of String) that contains a number of items selected by a user from a listbox. Now, I can use the list in a select clause like this:

Code:

SELECT * FROM Table WHERE Field IN ('" + List.Item(0) + "', '" + List.Item(1) + "', etc...
However, I do not know how many items the user will select from the listbox. Hence, I would like to do something like this (in pseudo code):

Code:

SELECT * FROM Table WHERE Field IN (List.AnyItem)
Does anyone have a clue how (if) this can be achieved? The only thing I can think of is to count the number of items in the list and use different select strings depending on the result, and that seems to me to be a a pretty ugly solution.

Any suggestion or idea is appreciated!

Viewing all articles
Browse latest Browse all 27101

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>