What does Dispose method do with the connection object?

Answer Posted / abhishek

SqlConnection.Dispose - in addition to closing the connection, it also
clears stateful nature of the SqlConnection instance, like connection string
etc.Beneath this layer, in SqlConnection atleast, there is a connection
pooling mechanism, which eventually holds actual physical database
connections. Again, they aren't really unmanaged resources, but non .NET
resources nonetheless. Lest I cause any confusion SqlClient has TDS parsing
built into .NET code, so technically in this scenario - there wasn't any
unmanaged resource.

So in short, Dispose does not **have** to release unmanaged resources - and
by convention it does cleanup. Thats exactly what SqlConnection.Dispse
does - "clean up clean up everybody do your share"

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain acid rule of thumb for transactions in c#.

695


What is IL / CIL / MSIL?

863


What are the principles of delegation?

692


What are cookies in c#?

742


Explain how obfuscator works in .net

724


What do you mean by stack and heap in c#?

647


Any problem found in vs.et

763


What are some examples of desktop applications?

677


What is the do while loop code?

657


Explain the Usage of web.config

756


If you define a user defined data type by using the class keyword, is it a value type or reference type?

698


Explain use of abstract and sealed classes in c#?

618


What is type safe in c#?

652


If I want to override a method one of class A and in class b then how do you declare?

928


Tell us something about static linking and dynamic linking?

710