Access Database exclusively locked - NOT

  • Thread starter Thread starter ACE FAN
  • Start date Start date
A

ACE FAN

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\wwwroot\Meeting1\Meeting1.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
 
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,
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
 
Oops, here's the code:
private void Page_Load(object sender, System.EventArgs e)
{
dbConn.Open();


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

Thanks
 
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.
 
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
 
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
 
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.
 
Back
Top