liorsolomon
asked on
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.OleDbExc eption: 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.OleDbCon nectionInt ernal..cto r(OleDbCon nectionStr ing constr, OleDbConnection connection) at System.Data.OleDb.OleDbCon nectionFac tory.Creat eConnectio n(DbConnec tionOption s options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.D bConnectio nFactory.C reateNonPo oledConnec tion(DbCon nection owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.D bConnectio nFactory.G etConnecti on(DbConne ction owningConnection) at System.Data.ProviderBase.D bConnectio nClosed.Op enConnecti on(DbConne ction outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbCon nection.Op en() at UserMail.Create_Mail_Displ ay() 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?
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.OleDbExc
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?
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.
I would try to help you but I haven't dealt much withe ASP.Net.
ASKER
Thanks
:)
:)
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.
S.
ASKER
The funny thing is that other scripts that uses the same connection string :
"Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=D:/vhosts/shaytubal y.org.il/h ttpdocs/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.
"Provider=Microsoft.Jet.OL
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.
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.
ASKER
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.
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I usually get that error when i have the table open in design view then try to use the table in my scripts.
ASKER
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
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
Yes - the access drivers use what is known as unmanageble code ... and this could be your problem.
Please see one of my previous answers
https://www.experts-exchange.com/questions/21877457/Error-when-trying-to-connect-to-Microsoft-Access-database-on-hosting-server.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
Please see one of my previous answers
https://www.experts-exchange.com/questions/21877457/Error-when-trying-to-connect-to-Microsoft-Access-database-on-hosting-server.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
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.
ASKER
Private Conn As New OleDb.OleDbConnection("Pro
Private Conn2 As New OleDb.OleDbConnection("Pro
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,
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