the difference betweenSqlConnection.IDisposable.Dispose() andSqlConnection.Dispose().

Discussion in 'Microsoft Dot NET Framework' started by tangyong, Jan 20, 2006.

  1. tangyong

    tangyong Guest

    All:
    I have a question about the difference between
    SqlConnection.IDisposable.Dispose() and SqlConnection.Dispose(). Both of them realize the function of releasing the connection to the ConnectionPool? Do they have the same effection source code? If they are different, who can tell me the differences? If they are same, why MS gives the SqlConnection.IDisposable.Dispose,but only SqlConnection.Dispose() method?
    In the MSDN, there are following description about the
    SqlConnection.IDisposable.Dispose Method:
    "This member supports the .NET Framework infrastructure and is not intended to be used directly from your code." what's the meaning of it?
    If the user has called the SqlConnection.IDisposable.Dispose() in the client application, what probem results in? and if there are some problem becomes, then why did MS give us such a method?
    in the same, who can tell me the using of
    "SqlConnection.ICloneable.Clone "
    "SqlConnection.IDbConnection.BeginTransaction" and
    "SqlConnection.IDbConnection.CreateCommand"?

    Best Regards!!
     
    tangyong, Jan 20, 2006
    #1
    1. Advertisements

  2. Re: the difference between SqlConnection.IDisposable.Dispose() and SqlConnection.Dispose().

    I think if you leave out the interface name, the compiler will choose the
    most sensible one for you (usually the object itself's implementation).

    If you explicitly selected to call through an interface name, you risk to do
    things wrong by chance the object itself choosen to override the method to
    do other things. For the purpose of SqlConnection.Dispose(), the object may
    have allocated some other resource that require to be freed on dispose, may
    need to ensure all datareaders/dataadapeters or so have been properly closed
    or so, while IDisposable.Dispose seems to just free up the object (and other
    object's in it)'s memory.

    <tangyong> ¼¶¼g©ó¶l¥ó·s»D:...
    > All:
    > I have a question about the difference between
    > SqlConnection.IDisposable.Dispose() and SqlConnection.Dispose(). Both of
    > them realize the function of releasing the connection to the
    > ConnectionPool? Do they have the same effection source code? If they are
    > different, who can tell me the differences? If they are same, why MS gives
    > the SqlConnection.IDisposable.Dispose,but only SqlConnection.Dispose()
    > method?
    > In the MSDN, there are following description about the
    > SqlConnection.IDisposable.Dispose Method:
    > "This member supports the .NET Framework infrastructure and is not
    > intended to be used directly from your code." what's the meaning of it?
    > If the user has called the SqlConnection.IDisposable.Dispose() in the
    > client application, what probem results in? and if there are some problem
    > becomes, then why did MS give us such a method?
    > in the same, who can tell me the using of
    > "SqlConnection.ICloneable.Clone "
    > "SqlConnection.IDbConnection.BeginTransaction" and
    > "SqlConnection.IDbConnection.CreateCommand"?
    >
    > Best Regards!!
    >
     
    Lau Lei Cheong, Jan 20, 2006
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Francois PIETTE

    IDisposable.Dispose, Object.Finalize and threads

    Francois PIETTE, May 5, 2004, in forum: Microsoft Dot NET Framework
    Replies:
    16
    Views:
    759
    Chad Z. Hower aka Kudzu
    May 7, 2004
  2. Marina

    Re: IDisposable and Strings

    Marina, Jul 7, 2004, in forum: Microsoft Dot NET Framework
    Replies:
    1
    Views:
    176
    Peter van der Goes
    Jul 7, 2004
  3. Guest

    Exception handling in IDisposable.Dispose

    Guest, Feb 2, 2005, in forum: Microsoft Dot NET Framework
    Replies:
    2
    Views:
    285
    Guest
    Feb 3, 2005
  4. Water Cooler v2

    About IDisposable.Dispose()

    Water Cooler v2, Sep 11, 2006, in forum: Microsoft Dot NET Framework
    Replies:
    6
    Views:
    226
    Brian Gideon
    Sep 15, 2006
  5. Bhuwan Bhaskar

    What is the difference between Dispose and close methods.

    Bhuwan Bhaskar, Oct 2, 2007, in forum: Microsoft Dot NET Framework
    Replies:
    9
    Views:
    578
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Oct 3, 2007
Loading...

Share This Page