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

Why delegate is used in c#?

0 Answers  


How long does it take to learn c# programming?

0 Answers  


Do void methods have parameters?

0 Answers  


What are extender provider components? Explain how to use an extender provider in the project.

0 Answers  


what are the advantages of c# over vb.net?

10 Answers   Choice Solutions, HCL, Practical Viva Questions,






how to access the virtual method without creating the objet for the virtual method?

1 Answers  


Why dictionary is used in c#?

0 Answers  


Hi, Can we implement the Abstract class on interface in c#, If yes then provide the code implementation

1 Answers   RHR, Wipro,


Why do we use namespace in c#?

0 Answers  


Does the variables of a private class-level inherited?

0 Answers   Siebel,


Why do we need generics?

0 Answers  


What is a generic method?

0 Answers  


Categories