It looks like the VB.Net code (System.Data.OleDb) that I've used in my Windows Service for a long time has been opening the Access 2003 database for queries in Exclusive Mode. I did not set that explicitly in my ConnectionString, I didn't even know it would matter. I'm not a database programmer, I just learned what I needed in order to write my application to use a database.
All I have had in the ConnectionString is "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Data\Data.mdb" and that has worked fine.
When we added a second Service to our product, which also queries the same database, we found a few instances of Exceptions with messages saying one of 3 things.
1. Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt.
2. Could not use ''; file already in use.
3. You attempted to open a database that is already opened exclusively by user 'Admin' on machine 'DEVELOPER'. Try again when the database is available.
I built a test app that would start a Thread that would continuously open, query, read, and close. Then I can run 10 of them at once and read the Exception messages that are written to a text file.
I studied on internet sites and thought I had the answer- I would explicitly add "Mode=Share Deny None" to the ConnectionString. But adding that results instead in errors that say "Could not lock file."
When I run it WITH the Mode property explicitly set, no .ldb file ever gets created. If I run it without the Mode set in code, the ldb files get created and deleted but still there are the first error message types.
And why does it tell me it can't open database ''? When I see references to that error on websites it has the database name in there.
Any ideas?
Thanks so much
All I have had in the ConnectionString is "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Data\Data.mdb" and that has worked fine.
When we added a second Service to our product, which also queries the same database, we found a few instances of Exceptions with messages saying one of 3 things.
1. Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt.
2. Could not use ''; file already in use.
3. You attempted to open a database that is already opened exclusively by user 'Admin' on machine 'DEVELOPER'. Try again when the database is available.
I built a test app that would start a Thread that would continuously open, query, read, and close. Then I can run 10 of them at once and read the Exception messages that are written to a text file.
I studied on internet sites and thought I had the answer- I would explicitly add "Mode=Share Deny None" to the ConnectionString. But adding that results instead in errors that say "Could not lock file."
When I run it WITH the Mode property explicitly set, no .ldb file ever gets created. If I run it without the Mode set in code, the ldb files get created and deleted but still there are the first error message types.
And why does it tell me it can't open database ''? When I see references to that error on websites it has the database name in there.
Any ideas?
Thanks so much