difference between managed connection and unmanaged connection

Posted by Rajeshk under Sql Server on 12/29/2012 | Points: 10 | Views : 1332 | Status : [Member] | Replies : 1
hi all,
can anyone differentiate the managed connection and unamanaged connection?



Posted by: Baimey on: 12/31/2012 [Member] Starter | Points: 25

The term "unmanaged resource" is usually used to describe something not directly under the control of the garbage collector.

For example, if you open a connection to a database server this will use resources on the server (for maintaining the connection) and possibly other non-.net resources on the client machine, if the provider isn't written entirely in managed code.

This is why, for something like a database connection, it's recommended you write your code thusly:

using (var connection = new SqlConnection("connection_string_here"))
// Code to use connection here

As this ensures that .Dispose() is called on the connection object, ensuring that any unmanaged resources are cleaned up.

Check this link http://stackoverflow.com/questions/3607213/what-is-meant-by-managed-vs-unmanaged-resources-in-net

Please Mark as Answer If this Helps

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response