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 are the benefits of using generics?

0 Answers  


Is c# good for games?

0 Answers  


What is unrecognized escape sequence in c#?

0 Answers  


from web.config file with connection string who to interact means who to connect in gridview. in my system shows null something error what is the problem

3 Answers   Bally Technologies,


What does || mean in programming?

0 Answers  


what is the difference between int and Int32?

5 Answers   TCS,


What is different between Static Constructor and Private Constructor?

0 Answers  


How to transpose multi-dimensional array?

0 Answers   C DAC, CDAC,


Is array reference type / value type ?

6 Answers   Accenture, BirlaSoft,


Is it possible to have a static indexer in c#?

0 Answers  


What are data types with examples?

0 Answers  


Is exe is machine dependent?

0 Answers  


Categories