Cannot Open Access File

Discussion in 'ASP .Net' started by dancer, Jul 9, 2007.

  1. dancer

    dancer Guest

    Using ASP.net 1.1 and Microsoft Access.

    I received the following error message. Why? I have closed the Access
    file. I have another very small access file that opens with no trouble with
    the same code, except a different name for the file.
    The Microsoft Jet database engine cannot open the file
    'C:\Inetpub\wwwroot\Accident.mdb'. It is already opened exclusively by
    another user, or you need permission to view its data.
     
    dancer, Jul 9, 2007
    #1
    1. Advertising

  2. dancer

    David Wier Guest

    First - have you ever been able to open it before, through the web page?
    If not - make sure the ASPNet user has 'Change' permissions on the folder
    where the Access file resides.

    --
    David Wier
    MVP/ASPInsider
    http://aspnet101.com
    http://iWritePro.com



    "dancer" <> wrote in message
    news:O$...
    > Using ASP.net 1.1 and Microsoft Access.
    >
    > I received the following error message. Why? I have closed the Access
    > file. I have another very small access file that opens with no trouble
    > with the same code, except a different name for the file.
    > The Microsoft Jet database engine cannot open the file
    > 'C:\Inetpub\wwwroot\Accident.mdb'. It is already opened exclusively by
    > another user, or you need permission to view its data.
    >
    >
    >
     
    David Wier, Jul 9, 2007
    #2
    1. Advertising

  3. dancer

    dancer Guest

    How do I give 'change' permissions? And why didn't I have to give
    persmissions on my other file?


    "David Wier" <> wrote in message
    news:...
    > First - have you ever been able to open it before, through the web page?
    > If not - make sure the ASPNet user has 'Change' permissions on the folder
    > where the Access file resides.
    >
    > --
    > David Wier
    > MVP/ASPInsider
    > http://aspnet101.com
    > http://iWritePro.com
    >
    >
    >
    > "dancer" <> wrote in message
    > news:O$...
    >> Using ASP.net 1.1 and Microsoft Access.
    >>
    >> I received the following error message. Why? I have closed the Access
    >> file. I have another very small access file that opens with no trouble
    >> with the same code, except a different name for the file.
    >> The Microsoft Jet database engine cannot open the file
    >> 'C:\Inetpub\wwwroot\Accident.mdb'. It is already opened exclusively by
    >> another user, or you need permission to view its data.
    >>
    >>
    >>

    >
    >
     
    dancer, Jul 9, 2007
    #3
  4. dancer

    sloan Guest

    Permissions, permissions permissions.

    ...

    access needs to create a ldb file, which basically is a internal file which
    says "userA is logged in" along with other stuff.
    but the account which asp.net runs under MUST have permissions to the mdb
    file, and to the directory to create/destroy this ldb file.



    "dancer" <> wrote in message
    news:...
    > How do I give 'change' permissions? And why didn't I have to give
    > persmissions on my other file?
    >
    >
    > "David Wier" <> wrote in message
    > news:...
    > > First - have you ever been able to open it before, through the web page?
    > > If not - make sure the ASPNet user has 'Change' permissions on the

    folder
    > > where the Access file resides.
    > >
    > > --
    > > David Wier
    > > MVP/ASPInsider
    > > http://aspnet101.com
    > > http://iWritePro.com
    > >
    > >
    > >
    > > "dancer" <> wrote in message
    > > news:O$...
    > >> Using ASP.net 1.1 and Microsoft Access.
    > >>
    > >> I received the following error message. Why? I have closed the Access
    > >> file. I have another very small access file that opens with no trouble
    > >> with the same code, except a different name for the file.
    > >> The Microsoft Jet database engine cannot open the file
    > >> 'C:\Inetpub\wwwroot\Accident.mdb'. It is already opened exclusively by
    > >> another user, or you need permission to view its data.
    > >>
    > >>
    > >>

    > >
    > >

    >
    >
     
    sloan, Jul 9, 2007
    #4
  5. "dancer" <> wrote in message
    news:...

    > How do I give 'change' permissions?


    Right-click on the folder, click Properties, Security...

    > And why didn't I have to give persmissions on my other file?


    When using Jet databases you don't just need write permissions on the .mdb
    file - you also need write permissions on the folder to allow the Jet engine
    to create the locking database (*.ldb) file...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 9, 2007
    #5
  6. "sloan" <> wrote in message
    news:...

    > access needs to create a ldb file


    Just to maintain a certain level of accuracy here, Microsoft Access is not
    actually involved in any of this process at any stage...

    The OP says he's "Using ASP.net 1.1 and Microsoft Access" - clearly, this is
    a web app so Microsoft Access isn't installed on the server (at least, I
    hope it isn't!)

    What we have here is a Jet database being interfaced through ADO.NET. When a
    Jet database is opened for shared access, it is the Jet engine which tries
    to create the locking (*.ldb) database.

    The error message which the OP is getting: "The Microsoft Jet database
    engine cannot open the file" is the key here.

    It is the Jet engine, not Microsoft Access, which is trying to open the Jet
    database, but it is unable to create the corresponding locking database due
    to insufficient folder permissions, and so throws the error.

    None of this has anything whatsoever to do with Microsoft Access...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 9, 2007
    #6
  7. dancer

    sloan Guest

    Good catch!

    Thanks Mark.

    However, I have found the error messages are sometimes a little "off" (not
    in this case, but in general) with access errors.
    Even the version of access might affect it I think.
    I've run some Access97 tests, and get weirdo error messages when the
    permissions aren't right.



    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "sloan" <> wrote in message
    > news:...
    >
    > > access needs to create a ldb file

    >
    > Just to maintain a certain level of accuracy here, Microsoft Access is not
    > actually involved in any of this process at any stage...
    >
    > The OP says he's "Using ASP.net 1.1 and Microsoft Access" - clearly, this

    is
    > a web app so Microsoft Access isn't installed on the server (at least, I
    > hope it isn't!)
    >
    > What we have here is a Jet database being interfaced through ADO.NET. When

    a
    > Jet database is opened for shared access, it is the Jet engine which tries
    > to create the locking (*.ldb) database.
    >
    > The error message which the OP is getting: "The Microsoft Jet database
    > engine cannot open the file" is the key here.
    >
    > It is the Jet engine, not Microsoft Access, which is trying to open the

    Jet
    > database, but it is unable to create the corresponding locking database

    due
    > to insufficient folder permissions, and so throws the error.
    >
    > None of this has anything whatsoever to do with Microsoft Access...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
     
    sloan, Jul 9, 2007
    #7
  8. "sloan" <> wrote in message
    news:...

    > However, I have found the error messages are sometimes a little "off" (not
    > in this case, but in general) with access errors.


    *Access* errors...?

    > Even the version of access might affect it I think.


    Version of *Access*...?

    > I've run some Access97 tests, and get weirdo error messages when the
    > permissions aren't right.


    You've installed Access 97 on your web server...???


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 9, 2007
    #8
  9. Access97 is a bit quirky for web access.
    I'd consider upgrading the database to Access 2000 or Access 2003.

    re:
    !> You've installed Access 97 on your web server...???

    I hope not.
    Access itself isn't needed on the server. Just the database.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Mark Rae [MVP]" <> wrote in message news:ucyKi%...
    > "sloan" <> wrote in message news:...
    >
    >> However, I have found the error messages are sometimes a little "off" (not
    >> in this case, but in general) with access errors.

    >
    > *Access* errors...?
    >
    >> Even the version of access might affect it I think.

    >
    > Version of *Access*...?
    >
    >> I've run some Access97 tests, and get weirdo error messages when the
    >> permissions aren't right.

    >
    > You've installed Access 97 on your web server...???


    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Juan T. Llibre, Jul 9, 2007
    #9
  10. "Juan T. Llibre" <> wrote in message
    news:...

    > Access97 is a bit quirky for web access.
    > I'd consider upgrading the database to Access 2000 or Access 2003.


    By which, of course, you mean that Jet 3.5 is a bit quirky for web access,
    and you'd consider upgrading the database to Jet 4.0 (Access 2000, 2002 and
    2003 all use the Jet 4.0 database by default)

    > Access itself isn't needed on the server. Just the database.


    Exactly - just the Jet database is needed on the server...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 9, 2007
    #10
  11. dancer

    dancer Guest

    "When using Jet databases you don't just need write permissions on the .mdb
    > file - you also need write permissions on the folder to allow the Jet
    > engine to create the locking database (*.ldb) file..."


    Which folder?
    >




    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "dancer" <> wrote in message
    > news:...
    >
    >> How do I give 'change' permissions?

    >
    > Right-click on the folder, click Properties, Security...
    >
    >> And why didn't I have to give persmissions on my other file?

    >
    > When using Jet databases you don't just need write permissions on the .mdb
    > file - you also need write permissions on the folder to allow the Jet
    > engine to create the locking database (*.ldb) file...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    dancer, Jul 10, 2007
    #11
  12. dancer

    dancer Guest

    I am using Access 2003. I know not what Jet version. I am testing on
    local host.
    I created another Access file, copied the data, saved it, and it opened just
    fine!!! But it probably will happen again.

    Now another problem: when I downloaded to my host server and tried to run it
    I got the following message.
    When I downloaded it, I got the message, "Do you want to change the database
    connection?" The first time I said no, the next time I said yes, but
    still got the same error message on trying to run it. Any help will be
    appreciated.

    Could not find file 'c:\windows\system32\inetsrv\Acc.mdb'.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.Data.OleDb.OleDbException: Could not find file
    'c:\windows\system32\inetsrv\Acc.mdb'.

    Source Error:

    Line 7: DBConnection = New
    OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;" & _
    Line 8: "Data Source=Acc.mdb" )
    Line 9: DBConnection.Open()
    Line 10:
    Line 11: Dim DBCommand As OledbCommand

    Source File: e:\accounts\whee13\WWW\database_acc_host.aspx Line: 9

    Stack Trace:

    [OleDbException (0x80004005): Could not find file
    'c:\windows\system32\inetsrv\Acc.mdb'.]
    System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20
    System.Data.OleDb.OleDbConnection.InitializeProvider() +57
    System.Data.OleDb.OleDbConnection.Open() +203
    ASP.database_Acc_host_aspx.Page_Load(Object sender, EventArgs e) in
    e:\accounts\whee13\WWW\database_acc_host.aspx:9
    System.Web.UI.Control.OnLoad(EventArgs e) +67
    System.Web.UI.Control.LoadRecursive() +35
    System.Web.UI.Page.ProcessRequestMain() +750





    "Mark Rae [MVP]" <> wrote in message
    news:uKkx%...
    > "Juan T. Llibre" <> wrote in message
    > news:...
    >
    >> Access97 is a bit quirky for web access.
    >> I'd consider upgrading the database to Access 2000 or Access 2003.

    >
    > By which, of course, you mean that Jet 3.5 is a bit quirky for web access,
    > and you'd consider upgrading the database to Jet 4.0 (Access 2000, 2002
    > and 2003 all use the Jet 4.0 database by default)
    >
    >> Access itself isn't needed on the server. Just the database.

    >
    > Exactly - just the Jet database is needed on the server...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    dancer, Jul 10, 2007
    #12
  13. "dancer" <> wrote in message
    news:...

    > I am using Access 2003.


    Have you actually installed a copy of Microsoft Access on your webserver?
    Yes or no?

    > I created another Access file,


    No you didn't! You created another Jet database! I know you *think* you're
    using Microsoft Access, but you really aren't...

    > DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;"


    See, there's the thing right there. Look at the Provider part of your
    connection string - it's using Jet 4...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 10, 2007
    #13
  14. "dancer" <> wrote in message
    news:...

    > "When using Jet databases you don't just need write permissions on the
    > .mdb
    >> file - you also need write permissions on the folder to allow the Jet
    >> engine to create the locking database (*.ldb) file..."

    >
    > Which folder?


    The folder that your Jet database is in...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 10, 2007
    #14
  15. dancer

    dancer Guest

    I went to my webserver to install the Microsoft Access. I have to enter the
    following:
    DSN name
    Path
    DSN Description
    Username
    Password
    1. What should I put for the DSN name?
    2. What should I put for the Path?
    3. By entering a Username and Password, will I have to include that
    somewhere in my code in order for my application to access the database?


    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "dancer" <> wrote in message
    > news:...
    >
    >> I am using Access 2003.

    >
    > Have you actually installed a copy of Microsoft Access on your webserver?
    > Yes or no?
    >
    >> I created another Access file,

    >
    > No you didn't! You created another Jet database! I know you *think* you're
    > using Microsoft Access, but you really aren't...
    >
    >> DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;"

    >
    > See, there's the thing right there. Look at the Provider part of your
    > connection string - it's using Jet 4...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    dancer, Jul 10, 2007
    #15
  16. "dancer" <> wrote in message
    news:...

    > I went to my webserver to install the Microsoft Access.


    Why on earth did you do that???

    Please go back to your webserver and uninstall Microsoft Access.

    I'm sorry to appear to be labouring the point here, but an mdb file IS NOT
    Microsoft Access.

    Microsoft Access is piece of software for creating database applications -
    it is not the database itself.

    Microsoft Access uses the Jet (mdb) database format.

    It is absolutely vital that you understand the difference.

    In order to use a Jet database, YOU DO NOT NEED A COPY OF MICROSOFT
    ACCESS!!!!!

    When ASP.NET uses an mdb file, it does not use Microsoft Access to
    communicate with it.

    A copy of Microsoft Access is NOT required in order for the .NET Framework
    to use an mdb file.

    > I have to enter the following: DSN name


    ??? You do not need a DSN name to communicate with a Jet database because
    you're using OleDb, not ODBC...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 10, 2007
    #16
  17. dancer

    dancer Guest

    I did NOT install Microsoft Access. The reason I went to my host server TO
    install it is because YOU asked,"Have you actually installed a copy of
    Microsoft Access on your webserver? Yes or no?" when I mentioned the error,
    "Could not find file 'c:\windows\system32\inetsrv\Acc.mdb'"
    Do you remember that? Why did you ask me that?
    On my server under the category of Database was the option of installing
    1.Microsoft Access DSN,
    2. Microsoft FoxPro DSN, or
    3. Microsoft SQL Server
    Nowhere does it mention "Jet"

    What is your reason as to why I get the above error when trying to run my
    file at my host server? Why is it looking for the file on my computer? I
    downloaded the acc.mdb file to the host. Nowhere in my code do I refer to
    "c:\windows, etc."



    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "dancer" <> wrote in message
    > news:...
    >
    >> I went to my webserver to install the Microsoft Access.

    >
    > Why on earth did you do that???
    >
    > Please go back to your webserver and uninstall Microsoft Access.
    >
    > I'm sorry to appear to be labouring the point here, but an mdb file IS NOT
    > Microsoft Access.
    >
    > Microsoft Access is piece of software for creating database applications -
    > it is not the database itself.
    >
    > Microsoft Access uses the Jet (mdb) database format.
    >
    > It is absolutely vital that you understand the difference.
    >
    > In order to use a Jet database, YOU DO NOT NEED A COPY OF MICROSOFT
    > ACCESS!!!!!
    >
    > When ASP.NET uses an mdb file, it does not use Microsoft Access to
    > communicate with it.
    >
    > A copy of Microsoft Access is NOT required in order for the .NET Framework
    > to use an mdb file.
    >
    >> I have to enter the following: DSN name

    >
    > ??? You do not need a DSN name to communicate with a Jet database because
    > you're using OleDb, not ODBC...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    dancer, Jul 10, 2007
    #17
  18. "dancer" <> wrote in message news:%...

    > I did NOT install Microsoft Access.


    That's good.

    > The reason I went to my host server TO install it is because YOU asked,
    > "Have you actually installed a copy of Microsoft Access on your webserver? Yes or no?"
    > when I mentioned the error, "Could not find file 'c:\windows\system32\inetsrv\Acc.mdb'"
    > Do you remember that?


    Yes I do.

    > Why did you ask me that?


    Because I wanted to make certain that you *hadn't* installed Microsoft Access on your webserver... :)

    > What is your reason as to why I get the above error when trying to run my
    > file at my host server? Why is it looking for the file on my computer? I
    > downloaded the acc.mdb file to the host. Nowhere in my code do I refer to
    > "c:\windows, etc."


    Because it can't find the Jet database, so it's looking in the folder it's currently running from instead...

    > DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=Acc.mdb"


    Where *precisely* on your webserver is the Acc.mdb Jet database? Is it in your web app's virtual directory, maybe in the App_Data subfolder...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 10, 2007
    #18
  19. re:
    !> DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=Acc.mdb"

    That connection assumes the mdb file is located in the c:\windows\system32\inetsrv directory.

    An OledbConnection expects a complete physical directory path,
    if the path is ,ocated outside the website's directory path :

    c:\somepath\someother dir\Acc.mdb

    or... a virtual path which can be translated by Server.MapPath.

    DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & Server.Mappath "/App_Data/Acc.mdb")

    Btw, Acc.mdb should *never* be placed anywhere but in the App_Data directory.
    As long as the mdb is in the App_Data dir, it cannot be downloaded via a direct link.

    Placing it in the root directory of your app allows hackers to download your database.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Mark Rae [MVP]" <> wrote in message news:...
    "dancer" <> wrote in message news:%...

    > I did NOT install Microsoft Access.


    That's good.

    > The reason I went to my host server TO install it is because YOU asked,
    > "Have you actually installed a copy of Microsoft Access on your webserver? Yes or no?"
    > when I mentioned the error, "Could not find file 'c:\windows\system32\inetsrv\Acc.mdb'"
    > Do you remember that?


    Yes I do.

    > Why did you ask me that?


    Because I wanted to make certain that you *hadn't* installed Microsoft Access on your webserver... :)

    > What is your reason as to why I get the above error when trying to run my
    > file at my host server? Why is it looking for the file on my computer? I
    > downloaded the acc.mdb file to the host. Nowhere in my code do I refer to
    > "c:\windows, etc."


    Because it can't find the Jet database, so it's looking in the folder it's currently running from instead...

    > DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=Acc.mdb"


    Where *precisely* on your webserver is the Acc.mdb Jet database? Is it in your web app's virtual directory, maybe in the
    App_Data subfolder...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Juan T. Llibre, Jul 10, 2007
    #19
  20. dancer

    dancer Guest

    Where *precisely* on your webserver is the Acc.mdb Jet database? Is it in your web app's virtual directory, maybe in the App_Data subfolder...?

    I tried it in the same place as my aspx file (the root)
    I also tried it in the database folder.


    "Mark Rae [MVP]" <> wrote in message news:...
    "dancer" <> wrote in message news:%...

    > I did NOT install Microsoft Access.


    That's good.

    > The reason I went to my host server TO install it is because YOU asked,
    > "Have you actually installed a copy of Microsoft Access on your webserver? Yes or no?"
    > when I mentioned the error, "Could not find file 'c:\windows\system32\inetsrv\Acc.mdb'"
    > Do you remember that?


    Yes I do.

    > Why did you ask me that?


    Because I wanted to make certain that you *hadn't* installed Microsoft Access on your webserver... :)

    > What is your reason as to why I get the above error when trying to run my
    > file at my host server? Why is it looking for the file on my computer? I
    > downloaded the acc.mdb file to the host. Nowhere in my code do I refer to
    > "c:\windows, etc."


    Because it can't find the Jet database, so it's looking in the folder it's currently running from instead...

    > DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=Acc.mdb"


    Where *precisely* on your webserver is the Acc.mdb Jet database? Is it in your web app's virtual directory, maybe in the App_Data subfolder...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    dancer, Jul 10, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page