Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not use '(unknown)'; file already in use

We have the problem, which I think should be easily resolvable, but just not sure how. We have the Windows 2003 Server with the Classic ASP application on it. The MSAccess database is used for data storage.

The application is designed in the way that it has a lot of includes.

The .asp page may open the DB connection and close it in the end of the page. At the same time the include that is included on the page may have the same database open as well.

The problem is that on the second open we're getting an error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Could not use '(unknown)'; file already in use

This is on our local configuration only - we don't own that project, but are helping customer to fix some items. Everything works just perfect on Customer side. When we set the read-only access to the database this error is not shown. So, it seems that the ADODB.Connection is opening the database in exclusive mode.

Anyone has any ideas how to fix that?

Thanks

like image 669
Denis Mazourick Avatar asked Jul 27 '11 16:07

Denis Mazourick


2 Answers

Ok. The issue was resolved. As I was saying in the question - the resolution was VERY SIMPLE. Instead of setting the IUSR_* Write permission to MDB file only, it was necessary to set the Write permission to the whole folder where the MDB file is stored. Strange, because I don't see any additional files created (meaning, like .ldb file, which is created during an exclusive DB open). But, it works now!

like image 113
Denis Mazourick Avatar answered Oct 20 '22 23:10

Denis Mazourick


As far as I remember from using Access in my first classic ASP days you can't have more than one connection opened in the same time pointing to the same physical .mdb file because once it's opened, it's locked. That's what I learned the hard way.

The solution for me was using one single Connection. Having very small website to manage, I just used Application level connection object, created and opened once in global.asa then used in all pages.
However this is not good for ordinary websites so you can write file called "database.asp" in there create and open the connection then include that file and use the connection object in your code, not forgetting to close it in the end of every page.

Hope this makes sense, I'll clarify if needed.

like image 33
Shadow Wizard Hates Omicron Avatar answered Oct 20 '22 21:10

Shadow Wizard Hates Omicron