connecting to an access db via dsn-less asp file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: connecting to an access db via dsn-less asp file

  1. #1
    Kevin Guest

    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?

  2. #2
    Terry Guest

    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?



  3. #3
    JS Guest

    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?

    >



  4. #4
    Paul Clement Guest

    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...;en-us;q253604


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

  5. #5
    Kevin Guest

    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?



  6. #6
    Rick Guest

    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?

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center