Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why call .Close() and .Dispose() on a connection.

562989Jun 4 2007 — edited Apr 1 2010
If, by the IDisposeable interface, both Dispose() and Close() are interchangeable, why is it suggested to call both? Why not just do:

using (IDbConnection conn = new OracleConnection("connString"))
{
IDbCommand cmd = conn.CreateCommand();
cmd.ExecuteNonQuery();
}

The using statement will call conn.Dispose(), which in turn calls Close() and releases the unmanaged resources.

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 29 2010
Added on Jun 4 2007
17 comments
18,511 views