Hi everyone,
i share my pics and my problem: https://imgur.com/a/poes3vI
I have a loop (pic2) in which i need read the some data link to my id….
However… the function works but during longer loops after a while it return as too many connection; in clients connection page (pic1) i saw that the previous query weren’t disposed but i think my code (pic 3-4) is correct…

my co-worker suggested me to read it in one query through inner join, but i prefer to find another way for 2 reason:
my way of code is to make a query and load the records as custom class in a list and i would have to navigate directly in datatable and it’ll be messy
i have to read external data for a lot of field and one-shot query will be messy and hard to manage for other people
any idea? thk for reading

p.s. my question on stackoverflow
If you were on my team I’d suggest you find at least a couple more ways to solve the business problem then come back to me with a recommendation once you’d considered them.

I had 3 ideas update to ‘using’ system my code -read all the data in the table then search for my row in the datatable (only 1 connection, but maybe takes too resources) -make 1 long query with dozens of innerjoin…
I dont know if i’m close to the solution or lighyear away

source