Access Database exclusively locked - NOT

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ACE FAN

    Access Database exclusively locked - NOT

    Hi,

    I;m a newbie trying to get through some examples in VS2003. I'm trying
    to open a small Access database using ADO.NET in an ASP.NET app usinig
    an oleDBConnection . I get the following error when openning the
    database:

    The Microsoft Jet database engine cannot open the file
    'C:\Inetpub\www root\Meeting1\M eeting1.mdb'. It is already opened
    exclusively by another user, or you need permission to view its data.

    The file is not opened or locked by anoyone else as far as I can tell.
    This also happens when I'm running outside of the IDE with VS shut
    down.

    Can I get a little help on this please?

    TIA.

    Curt

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Access Database exclusively locked - NOT

    Curt,

    If you are sure that no one else is running it, are you sure that you
    have the appropriate permissions? Not only in the file system, but with the
    database itself? The MDB can be password protected, in which case, you have
    to provide that in the connect string.

    If that is not the case, can you post a piece of sample code and the MDB
    so that we can try it?


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "ACE FAN" <ctabor@oneil.c om> wrote in message
    news:1105988685 .231666.31960@z 14g2000cwz.goog legroups.com...[color=blue]
    > Hi,
    >
    > I;m a newbie trying to get through some examples in VS2003. I'm trying
    > to open a small Access database using ADO.NET in an ASP.NET app usinig
    > an oleDBConnection . I get the following error when openning the
    > database:
    >
    > The Microsoft Jet database engine cannot open the file
    > 'C:\Inetpub\www root\Meeting1\M eeting1.mdb'. It is already opened
    > exclusively by another user, or you need permission to view its data.
    >
    > The file is not opened or locked by anoyone else as far as I can tell.
    > This also happens when I'm running outside of the IDE with VS shut
    > down.
    >
    > Can I get a little help on this please?
    >
    > TIA.
    >
    > Curt
    >[/color]


    Comment

    • ACE FAN

      #3
      Re: Access Database exclusively locked - NOT

      Nicholas,
      I am sure no one else is running it- it's just a little 3 table DB I
      threw together myself so no one would even want to run it even if they
      could. I can open it with Access just fine. I am using the default
      Admin user and a blank password in my connection string.

      -Curt

      Comment

      • ACE FAN

        #4
        Re: Access Database exclusively locked - NOT

        Oops, here's the code:
        private void Page_Load(objec t sender, System.EventArg s e)
        {
        dbConn.Open();


        Here's my connection string: (Test connection is successful at design
        time connection strinig build)
        this.dbConn.Con nectionString = @"Jet OLEDB:Global Partial Bulk
        Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet
        OLEDB:Database Password=;Data
        Source=""C:\Ine tpub\wwwroot\Me eting1\Meeting1 .mdb"";Password =;Jet
        OLEDB:Engine Type=5;Jet OLEDB:Global Bulk
        Transactions=1; Provider=""Micr osoft.Jet.OLEDB .4.0"";Jet OLEDB:System
        database=;Jet OLEDB:SFP=False ;Extended Properties=;Mod e=Share Deny
        None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System
        Database=False; Jet OLEDB:Don't Copy Locale on Compact=False;J et
        OLEDB:Compact Without Replica Repair=False;Us er ID=Admin;Jet
        OLEDB:Encrypt Database=False" ;

        Thanks

        Comment

        • Nicholas Paldino [.NET/C# MVP]

          #5
          Re: Access Database exclusively locked - NOT

          Ahh, but you aren't running it, are you? This is code for the PageLoad
          event handler in an ASP.NET page. By default, ASP.NET runs under the ASPNET
          local account, which has limited access to the local machine. Unless you
          changed it, it is trying to access it using a very limited permission set.

          You would have to change it to run under a different account in order to
          do this, or impersonate a user that has rights in the page itself.


          --
          - Nicholas Paldino [.NET/C# MVP]
          - mvp@spam.guard. caspershouse.co m

          "ACE FAN" <ctabor@oneil.c om> wrote in message
          news:1105989745 .518479.184980@ c13g2000cwb.goo glegroups.com.. .[color=blue]
          > Oops, here's the code:
          > private void Page_Load(objec t sender, System.EventArg s e)
          > {
          > dbConn.Open();
          >
          >
          > Here's my connection string: (Test connection is successful at design
          > time connection strinig build)
          > this.dbConn.Con nectionString = @"Jet OLEDB:Global Partial Bulk
          > Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet
          > OLEDB:Database Password=;Data
          > Source=""C:\Ine tpub\wwwroot\Me eting1\Meeting1 .mdb"";Password =;Jet
          > OLEDB:Engine Type=5;Jet OLEDB:Global Bulk
          > Transactions=1; Provider=""Micr osoft.Jet.OLEDB .4.0"";Jet OLEDB:System
          > database=;Jet OLEDB:SFP=False ;Extended Properties=;Mod e=Share Deny
          > None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System
          > Database=False; Jet OLEDB:Don't Copy Locale on Compact=False;J et
          > OLEDB:Compact Without Replica Repair=False;Us er ID=Admin;Jet
          > OLEDB:Encrypt Database=False" ;
          >
          > Thanks
          >[/color]


          Comment

          • ACE FAN

            #6
            Re: Access Database exclusively locked - NOT

            Thanks. I have changed the permissions of the ASPNET local account to
            match my own (also set it to Administrator's group) but to no avail.
            Should I, and how can I run the app as me instead of the ASPNET user?
            Curt

            Comment

            • ACE FAN

              #7
              Re: Access Database exclusively locked - NOT

              Thanks. I have changed the permissions of the ASPNET local account to
              match my own (also set it to Administrator's group) but to no avail.
              Should I, and how can I run the app as me instead of the ASPNET user?
              Curt

              Comment

              • Nicholas Paldino [.NET/C# MVP]

                #8
                Re: Access Database exclusively locked - NOT

                Curt,

                Be careful, in practice, you should not run a web app with an ASPNET
                account with elevated permissions.

                There are two ways to impersonate someone else. The first is to place
                the page in a directory, and then have the web.config file for that
                directory have the <identity> tag, where the impersonate attribute is set to
                true.

                You can also do it in code, by calling the Impersonate method on the
                WindowsIdentity class. Check the documentation on that method for more
                information on how to do this.


                --
                - Nicholas Paldino [.NET/C# MVP]
                - mvp@spam.guard. caspershouse.co m

                "ACE FAN" <ctabor@oneil.c om> wrote in message
                news:1105991057 .868297.211530@ z14g2000cwz.goo glegroups.com.. .[color=blue]
                > Thanks. I have changed the permissions of the ASPNET local account to
                > match my own (also set it to Administrator's group) but to no avail.
                > Should I, and how can I run the app as me instead of the ASPNET user?
                > Curt
                >[/color]


                Comment

                • ACE FAN

                  #9
                  Re: Access Database exclusively locked - NOT

                  Thanks Nicholas. I got access and will now deal with the security
                  issue. . .

                  Comment

                  Working...