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 the difference between function and method in c#?

0 Answers  


What is constructor overloading in c#?

0 Answers  


Why interface is required?

0 Answers  


what is c# command?

0 Answers  


Is arraylist generic in c#?

0 Answers  


What is ilasm.exe used for?

0 Answers  


Can you inherit multiple interfaces?

3 Answers  


what is a structure in c#

3 Answers   Cognizant,


what is the fastest way to concatenate strings in c sharp?

4 Answers   HCL,


Why is .net so popular?

0 Answers  


What is dataset and dataadapter in c#?

0 Answers  


How to find type of variable?

0 Answers   HCL,


Categories