New with Asp.net jet data error

cpopham

Junior Contributor
Joined
Feb 18, 2004
Messages
273
I am using a database to fill a datalist, but when I compile it, I get the following error:

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

Line 154:
Line 155:
Line 156: daAuthors.fill(dsAuthors1) ' <---- this is in red
Line 157: ' Store in a session variable
Line 158: Session("DSAuthors") = dsAuthors1

I have checked the database. It is not archived and mot opened. I can open it in Access. It does not have a password. I even created a new database and imported everything from the old database to the new one with the same results.

Any ideas?

Chester
 
I still can not get this to work. I just do not understand it. This is my first asp .net database app.
 
If you move the .mdb into the same folder as the web application (and update the connection string) does the problem go away? If so then it is probably due to permissions on the file and the ASPNET user account not having access to the .mdb
 
I tried moving it to the bin folder of my project and it is still erroring out on me. Someone said I may have my local user settings wrong for an anonymous connection?

Chester
 
I think I have it, but it is opening up my security. I went to the folder where the project and .mdb file are located. It is under my wwwroot directory which is already defauly internet shared. I then took the bin folder where the .mdb file is located and shared it on the network with allowing network users to change my files. I also went under web sharing for this folder on checked the Share this folder. Does that open up myh security to the internet? Also if I deploy this to a real IIS server and put the .mdb file another folder for security will I have the same issues?

Thanks, Chester
 
Are you opening it only during a postback or everytime the page is posted? Are you using a try catch block with the close method in the finally block? This would assure that you are not leaving the connection open anywhere.
The other issue would be the permissions. Have you tried impersonation? Do a search in this form on that. Basically you put a single line in your web.config file and your data access will then run under your windows login. If aspnet user doesn't have rights to the db then you need impersonation to run under a user that does have rights. It's usually good practice to NOT have your db in the virtual web folder as this makes it harder for infiltrators to gain access to it because they have to find it first. But putting it there for testing is fine.

Once you get past this small obstacle you are going to be happy with asp.net and how nicely it plays with Access. Don't give up on it.
 
cpopham said:
I am using a database to fill a datalist, but when I compile it, I get the following error:

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

Line 154:
Line 155:
Line 156: daAuthors.fill(dsAuthors1) ' <---- this is in red
Line 157: ' Store in a session variable
Line 158: Session("DSAuthors") = dsAuthors1

I have checked the database. It is not archived and mot opened. I can open it in Access. It does not have a password. I even created a new database and imported everything from the old database to the new one with the same results.

Any ideas?

Chester

When using an ASP application You have to set security permissions. So you have to right click the folder and click the security tab. Then if ASPNET isnt listed as a user then you need to add it. Then allow ASPNET read and write access. If you dont have the security tab when you right click the folder post and ill explain that.
 
AFterlife,
I right click the folder and then click on Sharing and Security... then where do I need to to add ASPNET?

Chester
 
No after you right click hit properties then hit security. If the security tab isnt there let me now and ill explain it to you.
 
cpopham said:
Okay, I am not seeing the security tab...
Ok. Go into windows explorer.Click tools then click folder options.Click view. Scroll down to the bottom. Simple sharing is probably checked. uncheck that and you can be more precise with your security. Now the security tab will be there. :D
 
Okay thanks that got the security working right. Now I need to add a user named ASPNET? Correct?

Chester
 
Back
Top