Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3752
  • Last Modified:

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

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
liorsolomon
Asked:
liorsolomon
  • 5
  • 3
  • 2
  • +2
1 Solution
 
liorsolomonAuthor Commented:
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
 
CyrexCore2kCommented:
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
 
liorsolomonAuthor Commented:
Thanks
:)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
SimonBlakeCommented:
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
 
liorsolomonAuthor Commented:
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
 
walkerkeCommented:
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
 
liorsolomonAuthor Commented:
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
 
walkerkeCommented:
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
 
walkerkeCommented:
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
 
davecestriaCommented:
I usually get that error when i have the table open in design view then try to use the table in my scripts.
0
 
liorsolomonAuthor Commented:
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
 
SimonBlakeCommented:
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
 
CyrexCore2kCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now