Re: What is the difference between Dispose and Close

Tech-Archive recommends: Fix windows errors by optimizing your registry



Regards connection pooling, I doubt there is a differnce between dispose and
close. All you have to do is look at the reflected code, dispose calls
close - KAPUT !! (and does a little bit more which has nothing to do with
pooling).

- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
----------------------------------------------------------------------------
---------------



"William (Bill) Vaughn" <billvaNoSpam@xxxxxxxxx> wrote in message
news:ewH0whGbFHA.2416@xxxxxxxxxxxxxxxxxxxxxxx
> Sourcery? Dispose and Close both return the connection to the pool. If
they
> were calling neither or the logic let the PSP sneak away without calling
one
> or the other, adding Dispose would do the trick--assuming it's actually
> called. I've seen lots of cases where developers pass a DataReader to
> another routine that fails to close the DataReader (assuming they
remembered
> to use the correct CommandBehavior). I've seen situations where the Close
> (or Dispose) is there, but the logic bypasses it if there is an exception
> (the Close is not in the Finally).
>
> Unless it's a bug (which I doubt), I don't expect that Dispose will cure
any
> more connection pool issues than Close. Is there a code example somewhere
> that shows that Dispose works where Close does not? If so, I know a number
> of folks on campus that would love to see it.
>
>
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> www.betav.com/blog/billva
> www.betav.com
> www.sqlreportingservices.net
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> __________________________________
>
>
> "Cor Ligthert" <notmyfirstname@xxxxxxxxx> wrote in message
> news:uH3U2KFbFHA.3132@xxxxxxxxxxxxxxxxxxxxxxx
> > Bill,
> >
> >> As far as pooling behavior, Dispose and Close both return the
Connection
> >> to the pool for reuse. Each of the .NET providers implements a
Connection
> >> pool--it's part of the core functionality.
> >>
> > Why were there than so many people in these newsgroup, who had problems
> > with the Connection Pool, for whom, after that I advised to change the
> > close for dispose (according to the messages from Angel), the Connection
> > pool problems were gone?
> >
> > Cor
> >
>
>


.



Relevant Pages

  • Re: Question about IDispose
    ... > SqlConnection.Close() if the connection is not already closed. ... > handles pooling just fine does). ... >to write a Dispose method that works properly with the pooling system ... >> are cheap, however, the reverse is true in a web environment. ...
    (microsoft.public.dotnet.languages.csharp)
  • 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: 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: .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)
  • Re: Question about IDispose
    ... connection pool is specifically setup to prevent object destruction because ... So the *fix cannot come from the Dispose layer. ... The benefits of pooling here make or break the website. ...
    (microsoft.public.dotnet.languages.csharp)