Can we close all known/unknown connections to database with the code?
I’m using Access database and my application gives the following error:
“Could not use ”; file already in use. “
I don’t know which connection is opened and no closed, so is there a way to close all application’s opened connections?
When working with disposable objects you should use
usingso they will get disposed, and in this case even closed, when leaving theusingblock. Your code should look something like:Read about OleDbConnection.
UPDATE: I missed that you were accessing an access database, so updated the code to use
OleDbConnectioninstead.