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

What do you know about WM_CHAR message?

571


What is array collection?

490


What does return do in unity?

539


What is argument in c#?

517


What is the difference between static and constant variables?

539






What is a predicate in c#?

479


What is an assembly in .net?

572


What is a string in c#?

477


Are arrays immutable c#?

515


Is char * null terminated?

520


What is reflection c#?

468


What is a method signature?

527


What is the base class of all classes in c#?

507


Which are the loop types available in c#?

493


What is ienumerable <> in c#?

476