unmanagedresources

Are the database-related objects such as connection object, command object, datareader, dataadapter,... unmanaged resources?


Are the database-related objects such as connection object, command object, datareader, dataadapter,... unmanaged resources?


Solution

  • The objects you refer to are part of the .NET framework, and are garbage-collectable. So in that sense they are managed resources.

    A better question would be, do these objects implement IDisposable? If they do, you can use the using keyword in C# to clean them up once they go out of scope, or call their dispose() method manually.

    An example of using the using keyword with SqlConnection and SqlDataAdapter objects is here:

    http://weblogs.asp.net/jasonsalas/archive/2005/02/08/368811.aspx