views:

14

answers:

1

Related Question

My code doesn't release a file handle even after I call dispose to an initialized OleDbException. Is there a way to explicitly force the program to release a file handle?

A: 

Not sure why your code doesn't close a handle after calling Dispose(), since that calls Close() behind the scenes, but the following may help you write the code in a manner seen commonly:

using (OleDbConnection conn = new OleDbConnection(connString))
{
    //your stuff here
    conn.Close();  //not necessary, but doesn't hurt
}

This will close your handle regardless of whether an exception was thrown or not. Using blocks will Close/Dispose resources at the end of the block.

byte
Really really odd. I'm actually making a call to both dispose and close.
Jonn