Re: Newing a static var?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



When you close or dispose your connection this internal object is released
and stored back in the pool.

Let's say I run an ad hoc query and created the connection via the
"using" statement. During the time that query is running, a data
reader opens, using the same connection string. This is two
connections from the pool right?

Once both have completed, they are disposed via the using statement.
Are both returned to the pool or just one since they are identical?

It would seem feasible to have both in the pool hanging around to avoid
blocking when two connections are needed, which is a high probability
for most apps...I'd think. Especially if a block of code throws an
exception and doesn't dispose of the connection. What happens to the
connection than?

Where exactly in the framework is the connection pool? Where are some
references on that?

Thanks,
Brett

.



Relevant Pages

  • Re: What is the difference between Dispose and Close
    ... Dispose and Close both return the connection to the pool. ... were calling neither or the logic let the PSP sneak away without calling one ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Close and Dispose argument
    ... > fact that even Microsoft is not clear on the issue. ... > connections from the pool is still a debate. ... > method removes the conneciton from the connection pool". ... > Your issue was forwarded to us here at Microsoft Courseware Support. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: .NET connection pool problems
    ... both Dispose and Close are acceptably best practices for ... closing a connection and returning it to the pool. ... Here is a snippet from the Data Access Architecture best practices article ...
    (microsoft.public.dotnet.framework.aspnet)
  • Close and Dispose argument
    ... here is an email conversation between me and Microsoft ... connections from the pool is still a debate. ... Programming with Microsoft ADO.NET" module 2, p 18: "Calling the Dispose ... method removes the conneciton from the connection pool". ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Max pool size reached exception when trying to open a new connection
    ... Hi i am wrapping the sqlconnection in using statement.so there is no ... doubt that dispose is not getting called on sqlconnection. ... prior to obtaining a connection from the pool. ...
    (microsoft.public.dotnet.framework.adonet)