Cannot open an access database from within an ASP.NET application

G

Guest

Hello:

When I tried to use an Access database, I get the following exception:

Server Error in '/WebGrid' Application
--------------------------------------------------------------------------------

The Microsoft Jet database engine cannot open the file 'D:\Program
Files\Infragistics\NetAdvantage 2005 Volume
2\ASP.NET\Samples\Data\samplebrowser.mdb'. It is already opened exclusively
by another user, or you need permission to view its data.

I made sure that the folder, Data, has full access to these two accouhts,
<machine_name>\aspnet and <machine_Name>\IWAM_machine_name

Can somebody tell me how I can resolve this issue? Thanks.

Venki
 
G

Grant Merwitz

1)
Is the database open?
If you have the database open in Access, you will get this exception.
So if you have the database open, close it and try again.

2)
If your sure you don't have the database open, check that its closed
properly.
When you open an Access database file for editing, it create a temp file
called "samplebrowser.idb".
When you close the database, that file disapears.
If its still there, the database may have not closed properly, try closing
it again

3) Lastly

Try setting persmissions to IUSR_<machine_name>,
thats the user IIS uses.
If you not sure, set full permissions to everyone just incase

HTH
 
G

Guest

Folder & File.
Also, check your IIS settings, are you using anonymous or integrated
security? That determins the user you need to set for permissions.
 
G

Guest

Curt:

In the website's security setting, Enable_Anonymous_Access is checked and
the it uses the account IUSER_<machine_Name> for access. And, I made sure
that this account has full access rights.

Also, Integrated Windows Authentication is checked as well.

Venki
 
G

Grant Merwitz

I never meant just in case --> " If you not sure, set full permissions to
everyone just incase"

I meant Just to TEST
 
G

Guest

Grant:

When I gave the account, Everybody, Full Control, it worked. Now, I have to
figure out who really needs that level of access.

Thanks.
 
J

Juan T. Llibre

To find out which account needs access permission,
save the following as identity.aspx and run it.

identity.aspx
-------------------
<%@ Page Language="VB" %>
<%@ Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = tmp
End Sub
</script>
<html>
<head>
<title>WindowsIdentity.GetCurrent.Name()</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
------------------

When you run that file, it will return the current ASP.NET identity,
i.e., the account ASP.NET is running as.

Give *that* account the access permissions to the directory and file.
 
G

Guest

Juan:

Thank you so much for thsi jewel. I came to know that Network Services needs
to have full control on this folder.

Venki
 
J

Juan T. Llibre

re:
Thank you so much for this jewel.

You're very much welcome, wenk.

I wrote that script, in desperation, after butting my head against
the wall for hours with exactly the same problem you were having.

It sure makes configuring ASP.NET permissions easier, doesn't it ?

;-)
 
J

Juan T. Llibre

You're very much welcome, Sabine.

Feel free to pass it along to anybody who needs it.
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top