What does Dispose method do with the connection object?
Answers were Sorted based on User's Feedback
Answer / 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 |
What is different between Boxing and Unboxing?
How do you declare a variable in c#?
What is xml serialization in c#?
Is char * null terminated?
What is the difference between abstract and virtual?
If I return out of a try/finally in c#, does the code in the finally-clause run?
Can we assign null value to integer?
What is void in c#?
How do I do implement a trace and assert?
What is a dynamic assembly?
What are managed providers?
What is the use of inheritance in c#?