Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2006

Tip: Looking for answers? Try searching our database.

the difference between SqlConnection.IDisposable.Dispose()  and  SqlConnection.Dispose().

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tangyong - 20 Jan 2006 03:00 GMT
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 - 20 Jan 2006 04:53 GMT
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:OyUa42WHGHA.3896@TK2MSFTNGP15.phx.gbl...
> All:
>  I have a question about the difference between
[quoted text clipped - 17 lines]
>
>  Best Regards!!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.