c# - Closing an OleDbConnection -
just general question, if open oledbconnection in program, should close @ point? ask because i've seen few tutorials presenter doesn't include statement close connection.
in specific circumstances, open connection access excel file, fill datatable , grab values. after though, there no reason me have connection open , i'm thinking cause issues if left open.
also, statement conn.close();
sufficient close connection?
yes, should close connection done it. if use connection in 1 method , not after again, close , dispose it, can cleaned up.
you should wrap creation of connection in using
statement since close , dispose connection when exception occurs.
using (oledbconnection conn = new oledbconnection(...)) { // use connection inside here }
Comments
Post a Comment