MS Access can't open file

S

semesm22

hello all, i am using asp.net with IIS on a Windows XP machine to open
an Access database, and i know that this topic has been posted on forums
hundreds of times, but i can't find an answer that works..

here is the problem, i m opening the database with OleDBConnenction and
OleDbCommand...but i get this error:

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

HOWEVER, when i put the database in D:\Database, it works just
fine.....i researched the forums to find an answer, i even found a topic
on MSDN, but that related to server based IIS, and not WIN XP, it was
talking about permissions to everyone, which is something not found on
WIN XP....the problem is that i am doing this for a college assignment,
and i need to hand in the database in the same folder that contains my
web forms and web.config and all that.....i tried to use
Server.MapPath("..\Database\Database.mdb"), but that also didn't
work....can anyone help please...

thanks
 
S

S. Justin Gengo

You need to give the account your website is running as (it could be
IIS_User or ASPNET depending on whether you have an Identity Impersonate tag
in your web.config file or not) read and write permissions to the folder
that your database is in. To do so navigate to that folder, right click on
it and click properties. If you don't see a "Security" tab in the properties
window for that folder you'll need to reveal it (It's hidden by default on
Windows XP). To reveal the security tab in a folder browsing window click
Tools - Folder Options and then click on the "View" tab. at the very bottom
of the Advanced settings list uncheck "Use simple file sharing"

Then when you right click a folder and choose properties you'll see a
"Security" tab where you may set the permissions.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
S

semesm22

thank you very very very much for that great post....i followed the
directions, and it worked great, once again thank you

sam
 
S

semesm22

i may have spoke too soon.....i was using VB.NET cause its faster to
work with....but when i tried it with ASP.NET, i still had the same
error message......i did the read write user permissions that you spoke
about, for both the folder that the database is in, and the folder that
the Solution file is in....

any ideas
 
S

S. Justin Gengo

Sam,

Let's start with what permissions you're setting on the folder. Which
account is your website running as IUSR or ASPNET?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
S

semesm22

i'm using IUSR...should i creat another...however, this is an
assignment, so the assessor is probably using IUSR
 
S

semesm22

i did some research, and found out about the ASPNET user account, and i
added that user to the .mdb file, and gave it write permission on the
file....so i can now use an absolute path which
"C:\Inetpub\wwwroot\Cinema\Database\database.mdb" ....
however, when i try to use a relative path, such as
"..\Database\database.mdb" i get an error that says

file "'C:\WINDOWS\system32\Database\Database.mdb" not found...why is it
looking inside C:\windows, when i m trying to just go outside the bin
folder that contains the solution's dll file

thanks again
sam
 
S

S. Justin Gengo

Sam,

Ok, I understand the problem now. When connecting to an access database you
have to specify the absolute path. But you can get the absolute path from
the relative path by using Server.MapPath("[Relative Path Here]") You should
still just need to give IUSR the permissions. Server.MapPath will return the
absolute path of the file based on the relative path. Do a Response.Write of
Server.MapPath to see what it is returning.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
S

S. Justin Gengo

Sam,

You're welcome. I'm glad I was able to help!

Happy programming,

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top