Re: Conn.Close & Conn.Dispose



Thank you both for your answers. I think I'll just use dispose from now on.

Whilst were on the subject, we had a situation recently where an application
was not releasing connections back into the connection pool, even though we
were calling both .close and .dispose. I'm afraid I dont have any more
details to hand, but I do know one of our developers spent a week on the
problem, eventually giving in and turning off connection pooling on the
server.

Has anyone come across this?

Thanks again,
Simon.


.



Relevant Pages

  • Re: VS2005 and SQL Express: Internal .Net Framework Data Provider
    ... connection object you use. ... public void CreateConnection{ ... // Close first and dispose the existing data reader is there ... release resources used by the object ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: C# and GDI Resources
    ... interface use unmanaged resources; i.e. they end up being a wrapper to ... The rule is, if the object has a Dispose or Close method, make SURE you ... your class opens a database connection when an object is instanciated ... method would make sure to Dispose the database connection. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SqlConnection.Dispose close connection?
    ... The fact is that the garbage collector in c# is a generational collector. ... But a connection could be kept for longer use of course; ... Dispose calls Close anyway. ... By doing so you ensure that the unmanaged resource (i.e., ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: 2 ways to close a connection
    ... that the fix did not come from calling dispose instead of close. ... > resources used by the object. ... It only closes the connection. ... > Explicitly disposing any object that uses unmanaged resources as soon as you ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Connection pooling...
    ... Lets say your class is "C" and the expensive objects it holds are A and B ... Dispose, and B was say an instance of a COM object. ... In that sense, calling dispose on a Connection object, does NOT Guarantee ... (WHEEZE COUGH COUGH!!) ...
    (microsoft.public.dotnet.framework.adonet)