Tuesday, January 19, 2010

C# too many database connections error

1 comment
Every database is having some number of connection limits which you can increase up to an extend.

But database can support up to an number of connections.

This error occurs when we open a connection and forget to close that. Verify each line of your code and make sure you had closed the connection after completing your database operations.

I had faced this error in C# My sql application. I had crossed verify my code and find a code where I am not closing my connection after completing my operations. I had simply write connection.Close(); and it had worked.

1 comments:

KeepingItSimple said...

This does not seem to make a clarification whether there is a using() pattern used or try catch finally used.

My recommendation would be to put the connection close and connection set to null in the finally block.