Skip to content
Advertisement

SQL statement that selects array values

I am working on a visual basic project. I have a mdb database connected to my project. I want to add a SELECT query that finds the results which are in array that i give it on my program

I have tried to write a statement like that:

But it does not work. In my page codes I have an array and I want to find results from "ogrenciler" table where the "kodu" is in my array.

Advertisement

Answer

Well, you could send that array to a temp table in Access, but that would prevent more then one user using the software at the same time. (or you could add some user name to the temp table. However, if the array of choices is small, say about max 50, then you can create the sql string.

eg:

So you can use the SQL format of:

And thus build up the “list”. The only downside to this approach is that the sql string is limited to 2000 characters. So, if your list is larger then say 50 or so items, then you have to adopt a different approach.

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