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
What is definition in c#?
Why do we use reflection in c#?
Why do we need properties in c#?
How to create events for a control? What is custom events? How to create it?
What is lock statement in C#?
Explain the types of comments in c#?
Where is the main method in c#?
what class is underneath the sortedlist class?
Explain the serialization in .net
What is datasource c#?
What is a generic method?
Is namespace a class?
What is a streamwriter in c#?
What is difference between ilist and list in c#?
What does namespace mean?