Reputation: 19
I have a static class handling my DB access. When I open an SqlConnection and access it multithreadedly - it closes by itself after 1-2 queries. Nowhere in my code I close it - any thoughts???
Thank you Waldo
Upvotes: 0
Views: 354
Reputation: 124814
When I open an SqlConnection and access it multithreadedly
Then don't access it "multithreadedly" - it's not thread-safe. Instead, open/close it on each thread, preferably with a using statement.
MSDN indicates that instance methods of this class are not thread-safe.
Upvotes: 2