Skip to content
Advertisement

SQL Select where values in List

Is there a way that I can create query against a data source (could be sql, oracle or access) that has a where clause that points to an ArrayList or List?

example:

I’ve seen some ways to do it with Linq, but I’d rather not resort to it if it’s avoidable.

Advertisement

Answer

You could use String.Join. Try something like this:

As a side note this will not protect you against SQL injection – hopefully this example will point you in the right direction.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement