What does Dispose method do with the connection object?

Answers were Sorted based on User's Feedback



What does Dispose method do with the connection object?..

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 does Dispose method do with the connection object?..

Answer / guest

Deletes it from the memory.

Is This Answer Correct ?    3 Yes 6 No

Post New Answer

More C Sharp Interview Questions

What is different between Boxing and Unboxing?

0 Answers  


How do you declare a variable in c#?

0 Answers  


What is xml serialization in c#?

0 Answers  


Is char * null terminated?

0 Answers  


What is the difference between abstract and virtual?

0 Answers  






If I return out of a try/finally in c#, does the code in the finally-clause run?

0 Answers  


Can we assign null value to integer?

0 Answers  


What is void in c#?

0 Answers  


How do I do implement a trace and assert?

0 Answers  


What is a dynamic assembly?

0 Answers  


What are managed providers?

0 Answers   UGC Corporation,


What is the use of inheritance in c#?

0 Answers  


Categories