Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

connecting to an access db via dsn-less asp file

THE ERROR:

-2147467259 (0x80004005)

[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine
cannot open the file '(unknown)'. It is already opened exclusively by another
user, or you need permission to view its data.

THE CODE: (the database is access '97)

<%
set conn = Server.CreateObject("ADODB.Connection")
connectstring = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("db/AccountingCheckRequestForm.mdb")
conn.Open connectstring
conn.Close
set conn = Nothing
%>

I cannot open the connection. The database does exist, the spelling is correct,
it is in the correct folder. I have tried to place it on my C drive and connect,
same error. I have created a new database, with a different name, updated
the code, same error. I do not have it open on my machine, nor on the server.
It is not an "exclusive" database. Any ideas?
[988 byte] By [Kevin] at [2007-11-9 17:47:42]
# 1 Re: connecting to an access db via dsn-less asp file
Why are you closing the connection string as soon as you open it? Try removing
"conn.Close" and "set conn = Nothing" and see what happens.

"Kevin" <a@aaa.com> wrote:
>
>THE ERROR:
>
>-2147467259 (0x80004005)
>
>[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine
>cannot open the file '(unknown)'. It is already opened exclusively by another
>user, or you need permission to view its data.
>
>THE CODE: (the database is access '97)
>
><%
>set conn = Server.CreateObject("ADODB.Connection")
>connectstring = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
> "DBQ=" & Server.MapPath("db/AccountingCheckRequestForm.mdb")
>conn.Open connectstring
>conn.Close
>set conn = Nothing
>%>
>
>I cannot open the connection. The database does exist, the spelling is correct,
>it is in the correct folder. I have tried to place it on my C drive and
connect,
>same error. I have created a new database, with a different name, updated
>the code, same error. I do not have it open on my machine, nor on the server.
>It is not an "exclusive" database. Any ideas?
Terry at 2007-11-11 23:17:48 >
# 2 Re: connecting to an access db via dsn-less asp file
Why can't you close the connection after you open it? There are no rules
to say you can't...its actually good code to close and set to nothing as
soon as you are done with the connection.

Here is the a REAL solution to your problem

"The Microsoft Jet database engine cannot open the file. It is already opened
exclusively by another user..."

Issue
When using Live Data mode or Preview in Browser, users get the error:

"The Microsoft Jet database engine cannot open the file. It is already opened
exclusively by another user..."

Reason
The account that is accessing the page doesn't have sufficient permissions
to lock the database. The account would be either the anonymous account (by
default the IUSR_computername) or a specific user account if the page has
been secured for authenticated access.

Solution
If you are using an Access file, it may not have proper permissions. To check
the permissions: 1 Find the database file in File Explorer.

2 Right-click and select properties.

3 Select the Security tab and click the Permissions button.
4 In the File Permissions dialog, make sure "Everyone" appears in the list
box with Full Control as the access type setting.

Note: Another cause for this error may be due to the fact that the Microsoft
Access file you are attempting to connect to is locked and a lock file (.ldb)
exists. If this is the case, search for any *.ldb files and delete them.
If another DSN (user or System) exists which is accessing the database, you
may want to delete it as well and ensure that a single DSN refers to the
database. Reboot the machine after making these changes.

"Terry" <noaddressgiven@work.com> wrote:
>
>Why are you closing the connection string as soon as you open it? Try removing
>"conn.Close" and "set conn = Nothing" and see what happens.
>
>
>
>"Kevin" <a@aaa.com> wrote:
>>
>>THE ERROR:
>>
>>-2147467259 (0x80004005)
>>
>>[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine
>>cannot open the file '(unknown)'. It is already opened exclusively by another
>>user, or you need permission to view its data.
>>
>>THE CODE: (the database is access '97)
>>
>><%
>>set conn = Server.CreateObject("ADODB.Connection")
>>connectstring = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
>> "DBQ=" & Server.MapPath("db/AccountingCheckRequestForm.mdb")
>>conn.Open connectstring
>>conn.Close
>>set conn = Nothing
>>%>
>>
>>I cannot open the connection. The database does exist, the spelling is
correct,
>>it is in the correct folder. I have tried to place it on my C drive and
>connect,
>>same error. I have created a new database, with a different name, updated
>>the code, same error. I do not have it open on my machine, nor on the server.
>>It is not an "exclusive" database. Any ideas?
>
JS at 2007-11-11 23:18:42 >
# 3 Re: connecting to an access db via dsn-less asp file
On 17 Dec 2002 11:41:02 -0800, "Kevin" <a@aaa.com> wrote:

THE ERROR:

-2147467259 (0x80004005)

[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine
cannot open the file '(unknown)'. It is already opened exclusively by another
user, or you need permission to view its data.

THE CODE: (the database is access '97)

<%
set conn = Server.CreateObject("ADODB.Connection")
connectstring = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("db/AccountingCheckRequestForm.mdb")
conn.Open connectstring
conn.Close
set conn = Nothing
%>

I cannot open the connection. The database does exist, the spelling is correct,
it is in the correct folder. I have tried to place it on my C drive and connect,
same error. I have created a new database, with a different name, updated
the code, same error. I do not have it open on my machine, nor on the server.
It is not an "exclusive" database. Any ideas?

It's a permissions issue. The authenticated web user (or anonymous user) does not have the
appropriate access to the folder where the database is located.

PRB: Microsoft Access Database Connectivity Fails in Active Server Pages
http://support.microsoft.com/default.aspx?scid=KB;en-us;q253604

Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)
Paul Clement at 2007-11-11 23:19:47 >
# 4 Re: connecting to an access db via dsn-less asp file
Thanks, it was a server permissions thing. I only open and closed the connection
to make sure I was actually connecting and not getting errors. Now that I
know it works, I will add the "stuff" in between.

Thanks all!

"Kevin" <a@aaa.com> wrote:
>
>THE ERROR:
>
>-2147467259 (0x80004005)
>
>[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine
>cannot open the file '(unknown)'. It is already opened exclusively by another
>user, or you need permission to view its data.
>
>THE CODE: (the database is access '97)
>
><%
>set conn = Server.CreateObject("ADODB.Connection")
>connectstring = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
> "DBQ=" & Server.MapPath("db/AccountingCheckRequestForm.mdb")
>conn.Open connectstring
>conn.Close
>set conn = Nothing
>%>
>
>I cannot open the connection. The database does exist, the spelling is correct,
>it is in the correct folder. I have tried to place it on my C drive and
connect,
>same error. I have created a new database, with a different name, updated
>the code, same error. I do not have it open on my machine, nor on the server.
>It is not an "exclusive" database. Any ideas?
Kevin at 2007-11-11 23:20:46 >
# 5 Re: connecting to an access db via dsn-less asp file
Be aware, you should put/have the data base in an isolated folder, so that
when you set the permissions allowing the user to create the necessary locks
you don't allow the user to also have permissions to code/other files which
is considered a security hole!

"Kevin" <a@aaa.com> wrote:
>
>Thanks, it was a server permissions thing. I only open and closed the connection
>to make sure I was actually connecting and not getting errors. Now that
I
>know it works, I will add the "stuff" in between.
>
>Thanks all!
>
>"Kevin" <a@aaa.com> wrote:
>>
>>THE ERROR:
>>
>>-2147467259 (0x80004005)
>>
>>[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine
>>cannot open the file '(unknown)'. It is already opened exclusively by another
>>user, or you need permission to view its data.
>>
>>THE CODE: (the database is access '97)
>>
>><%
>>set conn = Server.CreateObject("ADODB.Connection")
>>connectstring = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
>> "DBQ=" & Server.MapPath("db/AccountingCheckRequestForm.mdb")
>>conn.Open connectstring
>>conn.Close
>>set conn = Nothing
>>%>
>>
>>I cannot open the connection. The database does exist, the spelling is
correct,
>>it is in the correct folder. I have tried to place it on my C drive and
>connect,
>>same error. I have created a new database, with a different name, updated
>>the code, same error. I do not have it open on my machine, nor on the server.
>>It is not an "exclusive" database. Any ideas?
>
Rick at 2007-11-11 23:21:45 >