Permissions Error When Accessing Access Database

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

When I attempt to access a Microsoft Access database from my website, I
recieve the following error:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Security Exception
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the
permission of type 'System.Data.OleDb.OleDbPermission, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.


Take note that the description says that this can be fixed by modifying the
configuration file, which I am assuming is referring to the Web.config file.
I have successfully run this application on my machine using Visual Studio
2005's Development Server with the settings currently in the Web.config
file, so if modifying the Web.config file will fix it, what do I need to
change? Thanks.
 
When I attempt to access a Microsoft Access database from my website, I
recieve the following error:

Server Error in '/' Application.
---------------------------------------------------------------------------­-----

Security Exception
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the
permission of type 'System.Data.OleDb.OleDbPermission, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Take note that the description says that this can be fixed by modifying the
configuration file, which I am assuming is referring to the Web.config file.
I have successfully run this application on my machine using Visual Studio
2005's Development Server with the settings currently in the Web.config
file, so if modifying the Web.config file will fix it, what do I need to
change? Thanks.


Why do you use OleDb for MS Access?

http://msdn2.microsoft.com/en-us/library/system.data.oledb.oledbconnection.aspx

An application that creates an instance of the OleDbConnection object
can require all direct and indirect callers to have sufficient
permission to the code by setting declarative or imperative security
demands. OleDbConnection makes security demands using the
OleDbPermission object. Users can verify that their code has
sufficient permissions by using the OleDbPermissionAttribute object.
Users and administrators can also use the Code Access Security Policy
Tool (Caspol.exe) to modify security policy at the computer, user, and
enterprise levels. For more information, see Code Access Security and
ADO.NET.

http://msdn2.microsoft.com/en-us/library/0x4t63kb.aspx
 
I use OleDb for MS Access because of the namespaces that are included in the
..NET Framework (or that I have ever heard of from third parties)
System.Data.OleDb is the one that is supposed to be used when accessing a MS
Access database. The reason I am using MS Access for this website rather
than a higher quality database such as SQL Server or Oracle is because the
organization the site is for cannot afford anything else.

I have used System.Data.OleDb for MS Access databases in other sites I have
written, such as my personal website, with no problem, and any books that I
have read that use MS Access as their example database have as well, so I
know that it is the right one to use.

I have never had to deal with any of the objects you mention (except for
OleDbConnection, of course). Could you please either give me a code sample
or direct me to a site that gives one? Thanks.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

When I attempt to access a Microsoft Access database from my website, I
recieve the following error:

Server Error in '/' Application.
---------------------------------------------------------------------------­-----

Security Exception
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the
permission of type 'System.Data.OleDb.OleDbPermission, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Take note that the description says that this can be fixed by modifying
the
configuration file, which I am assuming is referring to the Web.config
file.
I have successfully run this application on my machine using Visual Studio
2005's Development Server with the settings currently in the Web.config
file, so if modifying the Web.config file will fix it, what do I need to
change? Thanks.


Why do you use OleDb for MS Access?

http://msdn2.microsoft.com/en-us/library/system.data.oledb.oledbconnection.aspx

An application that creates an instance of the OleDbConnection object
can require all direct and indirect callers to have sufficient
permission to the code by setting declarative or imperative security
demands. OleDbConnection makes security demands using the
OleDbPermission object. Users can verify that their code has
sufficient permissions by using the OleDbPermissionAttribute object.
Users and administrators can also use the Code Access Security Policy
Tool (Caspol.exe) to modify security policy at the computer, user, and
enterprise levels. For more information, see Code Access Security and
ADO.NET.

http://msdn2.microsoft.com/en-us/library/0x4t63kb.aspx
 
Back
Top