I am using the OleDbDataReader class in my c# project and my program keep locking up my mdb file after it runs. I am wondering how do I close my connection reliably at the end to release the lock. And if I need to close it everytime I run a query or can I just do it all in one go at the end of the program. Here is how I am setting it up:
private OleDbConnection myDbC = new OleDbConnection(connectionString);
myDbC.Open();
And here is how I use it, many many times:
OleDbCommand cmd = new OleDbCommand(SQL, myDbC);
OleDbDataReader reader = cmd.ExecuteReader();
reader.Close();
When the program finishes, I also do the following:
myDbC .Close();
So this is somehow locking up the mdb file. Any help?