Cannot Open Access File

D

dancer

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.
 
D

David Wier

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.
 
D

dancer

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

sloan

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.
 
M

Mark Rae [MVP]

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...
 
M

Mark Rae [MVP]

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...
 
S

sloan

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.
 
M

Mark Rae [MVP]

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...???
 
J

Juan T. Llibre

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.
 
M

Mark Rae [MVP]

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...
 
D

dancer

"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?
 
D

dancer

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
 
M

Mark Rae [MVP]

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...
 
D

dancer

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?
 
M

Mark Rae [MVP]

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...
 
D

dancer

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."
 
M

Mark Rae [MVP]

dancer said:
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...?
 
J

Juan T. Llibre

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.





dancer said:
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...?
 
D

dancer

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.


"dancer said:
> 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top