John,
There is only one reason I can think of where adding command dispose would
seem to fix your problem, and since it does not really fix it I need to ask.
Are you closing your connection in a Finalizer (destructor)?
This is one of the most common problems with people starting to use the .net
framework and we have not done a very good job of putting out the message,
you cant use finalizers to clean up managed resources, period.
If you are disposing the connection in a finalizer you will get stress
related errors in production, this problem was so bad that I had to add the
following comment to SqlConnection Close documentation:
http://msdn.microsoft.com/library/de...sposetopic.asp
CAUTION Do not call Close or Dispose on a Connection, a DataReader, or
any other managed object in the Finalize method of your class. In a
finalizer, you should only release unmanaged resources that your class owns
directly. If your class does not own any unmanaged resources, do not include
a Finalize method in your class definition. For more information, see
Programming for Garbage Collection.
Hope this helped,
--
Angel Saenz-Badillos [MS] Managed Providers
This posting is provided "AS IS", with no warranties, and confers no
rights.Please do not send email directly to this alias.
This alias is for newsgroup purposes only.
"john bailo" <jb****@vestcom.com> wrote in message
news:31******************************@news.teranew s.com...
"Michael Bird" <birdm @ symbol . com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... I'm assuming that since you are asking this wuestion, you don't expect
your code to have a lot of concurrent open connections to your SQL data
source. I would quess that you are not closing your connections correctly when
your are finished with them and are running out of available connections.
Yes, and no. I guess I had to refine my ideas about what 'closing a
connection' means.
I was closing the mySqlConnection, but I did not dispose the mySqlCommand
however.
Now my squence after consuming a Connection/Command set is:
mySqlCommand.Dispose
mySqlConnection.Close
mySqlConnection.Dispose
"john bailo" <jb****@vestcom.com> wrote in message
news:24******************************@news.teranew s.com... SqlConnection.Open, from a web application, threw:
/Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool. This may have occurred because all pooled
connections were in use and max pool size was reached./
What would cause this error?