I have a long block of code that makes about 10 or 12 different parameterized queries against SQL server. Some are readers others are NonQuery. My question is what is the best way to manage the connection(s) to optimize performance.
One way I had was opening and closing the connection after each execute, that required a lot more code.
So I moved to a single connection and a single command and just cleared the parameters out and added them back each and every time. That seemed to work okay but I'm having issues with timeouts accessing the db on what seem like simple queries after about 5 queries into the code. Could it be that I need to close the connection at least every now and then?
Any general suggestions on how to maintain this kind of scenario best?
Thanks
One way I had was opening and closing the connection after each execute, that required a lot more code.
So I moved to a single connection and a single command and just cleared the parameters out and added them back each and every time. That seemed to work okay but I'm having issues with timeouts accessing the db on what seem like simple queries after about 5 queries into the code. Could it be that I need to close the connection at least every now and then?
Any general suggestions on how to maintain this kind of scenario best?
Thanks