Connection Pools Question

  • Thread starter Thread starter William Reyes
  • Start date Start date
W

William Reyes

I get the following error from my object periodically.

"System.InvalidOperationException. Timeout Expired. The timeout period
elapsed prior to obtaining a connection from the pool. This may have
occurred because all polled connections were in use and the max pool size
was reached."

My object only has one connection object from which all methods perform
database operations. Other objects within my app are coded the same way each
with just one connection object.

I thought when connections are made using the same connection string the
ado.net handled the conection polling automatically.

Is there any way to explicitly remove unused connections from the pool?
Is it possible I am leaving too many connections open?

Should I be closing and "killing the connection object prior to the
destructionr of my object, maybe in the finalizer??

I am just not sure.

Any help would be greatly appreciated.
 
There is a way when making a connection to specify a value in the connection
string that will prevent the connection from being pooled for that
connection.

I do this with connections that are just used to authenticate the user.
Sometimes I am just checking if the user is allowed to do something. This
helps reduce connections in the pool on a busy system. You do get a
performance penalty but it is not as bad as this is made out to be and does
serve a purpose
 
Back
Top