Solved

Problem:"It is already opened exclusively by another user, or you need permission to view its data"

Posted on 2006-07-12
14
3,415 Views
Last Modified: 2008-01-09
Hi,
I'm a newbie to asp.net, and I'm facing a very anoying problem.
All I'm trying to do is connect to an access db and query some tables
I'm getting this error which doesn't makes sense to me:

System.Data.OleDb.OleDbException: The Microsoft Jet database engine cannot open the file 'D:\mypath\db.mdb'. It is already opened exclusively by another user, or you need permission to view its data. at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbConnection.Open() at UserMail.Create_Mail_Display() in ....

I'm using the same code for different scripts on the site and I don't get this message.
So obviously it can't be some script opening it exclusivly.
I have a feeling its more of a IIS setup issue.

Could someone help?
0
Comment
Question by:liorsolomon
  • 5
  • 3
  • 2
  • +2
14 Comments
 

Author Comment

by:liorsolomon
ID: 17095012
I forgot to add the code:

Private Conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/vhosts/shaytubaly.org.il/httpdocs/db.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False")
Private Conn2 As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/vhosts/shaytubaly.org.il/httpdocs/db.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False")

      Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Create_Mail_Display()
      End Sub

      Sub Create_Mail_Display()
            Dim strsql As String = "Select * From MailList M ORDER BY M.Ordered"
            Dim ObjCmd As New OleDb.OleDbCommand(strsql, Conn)
            Dim SchdlCmd As New OleDb.OleDbCommand
            Dim objReader As OleDb.OleDbDataReader
            Dim ScheduleReader As OleDb.OleDbDataReader
            Try
                  ObjCmd.Connection.Open()
                  objReader = ObjCmd.ExecuteReader()
            Catch ex As Exception
                  Response.Write(ex.ToString)
                  Response.End
            End Try

It throws the exception and steps out

Thanks
0
 
LVL 14

Expert Comment

by:CyrexCore2k
ID: 17095630
You might get a better response if you post this in the ASP.Net section.

I would try to help you but I haven't dealt much withe ASP.Net.
0
 

Author Comment

by:liorsolomon
ID: 17098287
Thanks
:)
0
 
LVL 7

Expert Comment

by:SimonBlake
ID: 17098913
Did you have the database open viewing the same table at the time you made the request - Access quite often seems to lock it open if I start Access first then browse it with a page. To get round this I setup queries to match the table and only open those in access and use the same ones in the asp.net code calls.

S.
0
 

Author Comment

by:liorsolomon
ID: 17100513
The funny thing is that other scripts that uses the same connection string :
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/vhosts/shaytubaly.org.il/httpdocs/db.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False" are succeding to query the mdb file.
But this specific aspx file doesn't.
Could it be that asp.net has different permission vs asp permission to files at the virtual directory? because I do succeed to connect to the mdb while using an asp file.
0
 
LVL 11

Expert Comment

by:walkerke
ID: 17103111
Check the security permissions on the folder which contains the database file. IUSER_servername (where "servername" is the name of your server) needs write permissions in that folder in order to create a temp file there.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:liorsolomon
ID: 17103609
As i said before,
If that was the problem, I couldn't read the data in any way.
There are few scripts that succeeds to read from that file. so it can't be the permissions of the file or directory.
0
 
LVL 11

Expert Comment

by:walkerke
ID: 17103797
If the permissions are not correct, queries that do not require a temp file would execute without errors. Other queries would cause the above error. Believe me, I've tripped over this error often enough. That's the first thing I check -- make sure that IUSER_servername has full control of the folder containing the mdb file.
0
 
LVL 11

Accepted Solution

by:
walkerke earned 125 total points
ID: 17103867
I've been putting an extra letter in the user account. It should be IUSR_servername where "servername" is the name of your server.
0
 
LVL 6

Expert Comment

by:davecestria
ID: 17106368
I usually get that error when i have the table open in design view then try to use the table in my scripts.
0
 

Author Comment

by:liorsolomon
ID: 17199507
Hi everyone,
I afraid I quite confused everyone with my problem
a deeper investigation discovered that the problem is related to the fact that only asp.net script can't access the db.
If i try any asp files to connect to the db it works perfectly, but if I try .net i get the error.
Is there any permissions issues regarding .net framework accessing access files?

Thanks
0
 
LVL 7

Expert Comment

by:SimonBlake
ID: 17199541
Yes - the access drivers use what is known as unmanageble code ... and this could be your problem.

Please see one of my previous answers
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21877457.html

It .net 2.0 there is a setting to allow DB access to be overriden in terms of the unmanagable code ... kinda like don't run unless its for database purposes... Altho I can't remember where the setting is - and this assumes you are running 2.0
0
 
LVL 14

Expert Comment

by:CyrexCore2k
ID: 17203012
Hey liorsolomon you should seriously consider switching to MySQL. If you've been doing this awhile switching to a full fledged DB engine is a good idea.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now