Access Connection problem in aspx page
am 20.11.2006 07:36:02 von gary
I have problem that DB connection Access file in ASP.NET code just does not
work. Error message likes this:
----------------------------
Exception Details: System.Data.OleDb.OleDbException: The Microsoft Jet
database engine cannot open the file 'C:\db\Northwoods.mdb'. It is already
opened exclusively by another user, or you need permission to view its data.
Source Error:
Line 169: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Line 170: 'Put user code to initialize the page here
Line 171: OleDbDataAdapter1.Fill(dsStudent)
Line 172: DataGrid1.DataBind()
Line 173:
--------------------------
The exception is on line 171. I know the that access db is not opened. So
the problem seems about the permission.
When at design time, in VS.NET, I have used Server Explorer / Data
Connection to create connection to the Access file and have tested connection
with no problem. Only when run it in aspx page, it got above problem.
Please help!!!
Thanks
gary
Re: Access Connection problem in aspx page
am 20.11.2006 09:30:55 von Mike Brind
"gary" wrote in message
news:F6802577-4AD9-49AA-8003-FB25F0E72AE5@microsoft.com...
>I have problem that DB connection Access file in ASP.NET code just does not
> work. Error message likes this:
>
> ----------------------------
> Exception Details: System.Data.OleDb.OleDbException: The Microsoft Jet
> database engine cannot open the file 'C:\db\Northwoods.mdb'. It is already
> opened exclusively by another user, or you need permission to view its
> data.
>
> Source Error:
>
>
> Line 169: Private Sub Page_Load(ByVal sender As System.Object, ByVal e
> As
> System.EventArgs) Handles MyBase.Load
> Line 170: 'Put user code to initialize the page here
> Line 171: OleDbDataAdapter1.Fill(dsStudent)
> Line 172: DataGrid1.DataBind()
> Line 173:
>
> --------------------------
>
> The exception is on line 171. I know the that access db is not opened. So
> the problem seems about the permission.
>
> When at design time, in VS.NET, I have used Server Explorer / Data
> Connection to create connection to the Access file and have tested
> connection
> with no problem. Only when run it in aspx page, it got above problem.
>
This group deals with classic asp which is totally different to dotnet.
Dotnet has its own group: microsoft.public.dotnet.framework.aspnet. Future
questions are better directed there.
However, you need to ensure that the user has modify permissions on the
folder that holds the database. This is because Access needs to create an
ldb (lock) file in the same folder as the db. The user in the context of
your application is ASPNET. The reason that it will work ok in VS.NET is
because that programme is running under your username, which already has the
appropriate permissions.
--
Mike Brind
Re: Access Connection problem in aspx page
am 20.11.2006 13:59:44 von reb01501
gary wrote:
> I have problem that DB connection Access file in ASP.NET code just
> does not work. Error message likes this:
>
> ----------------------------
> Exception Details: System.Data.OleDb.OleDbException: The Microsoft Jet
> database engine cannot open the file 'C:\db\Northwoods.mdb'. It is
> already opened exclusively by another user, or you need permission to
> view its data.
>
As Mike says, you can be more assured of getting a dotnet question answered
by posting it in a dotnet group. However, in this case the answer is the
same regardless of the platform: file-sytem permissions. All users of an
Access databse require read/write (Modify) permissions for the _folder_
containing the database file. The reason for this is that Jet uses a
"semaphore" locking strategy, using a locking file with an extension of .ldb
to control multi-user activity in the corresponding .mdb file. The first
user of the database needs to be able to create the ldb file. Subsequent
users need to be able to modify it. And the last user to exit the database
must be able to delete the file.
So, if your website is using anonymous access, the aspnet user account needs
Modify permissions for the folder. Otherwise, all users must be granted
permissions, usually by means of a group.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"