title: how to solve error System.Data.OleDb.OleDbPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed
body: <p>i am having this error while uploading my website to server   but in local host its working fine how to solve this error</p>
  
  <pre><code>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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
  
  Source Error:
  
  
  Line 32:         //con = new SqlConnection(constr);
  Line 33:         con = new OleDbConnection(constr);
  Line 34:         con.Open();
  Line 35: 
  Line 36: 
  </code></pre>
  
  <p>My web config file </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;configuration&gt;
    &lt;configSections&gt;
  
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
    &lt;/configSections&gt;
    &lt;connectionStrings&gt;
      &lt;add name="air" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\ICPSIndia.mdb;"/&gt;
      &lt;add name="libraryconnection" connectionString="Data Source=11.11.11.11;Initial Catalog=library;Persist Security Info=True;User ID=myid;Password=mypass;"/&gt;
    &lt;/connectionStrings&gt;
    &lt;appSettings&gt;
      &lt;add key="webpages:Version" value="3.0.0.0" /&gt;
      &lt;add key="webpages:Enabled" value="false" /&gt;
      &lt;add key="ClientValidationEnabled" value="true" /&gt;
      &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
    &lt;/appSettings&gt;
  
  
    &lt;system.web&gt;
  
      &lt;customErrors mode="Off"/&gt;
  
      &lt;authentication mode="Windows"/&gt;
  
  &lt;httpRuntime requestValidationMode="2.0" /&gt; 
  
      &lt;compilation debug="true" targetFramework="4.5.1" /&gt;
  
    &lt;/system.web&gt;
  
    &lt;system.webServer&gt;
      &lt;validation validateIntegratedModeConfiguration="false"/&gt;
      &lt;modules&gt;
        &lt;remove name="FormsAuthenticationModule" /&gt;
      &lt;/modules&gt;
      &lt;handlers&gt;
        &lt;add name="AjaxFileUploadHandler" verb="POST" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/&gt;
      &lt;/handlers&gt;
  
  
    &lt;/system.webServer&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-5.1.0.0" newVersion="5.1.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
    &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt;
        &lt;parameters&gt;
          &lt;parameter value="v11.0" /&gt;
        &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
      &lt;providers&gt;
        &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;
      &lt;/providers&gt;
    &lt;/entityFramework&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>my class file for conection</p>
  
  <pre><code>using System;
  using System.Data;
  //using System.Data.SqlClient;
  using System.Data.OleDb;
  //using System.Data.SqlClient;
  using System.Configuration;
  
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.HtmlControls;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  
  
  /// &lt;summary&gt;
  /// Summary description for Class1
  /// &lt;/summary&gt;
  public class Class1
  {
      public OleDbConnection con;
      public OleDbCommand cmd;
      public OleDbDataReader dr;
  
      String constr;
      public Class1()
      {
          constr = ConfigurationManager.ConnectionStrings["air"].ToString();
      }
      public void conopen()
      {
          //con = new SqlConnection(constr);
          con = new OleDbConnection(constr);
          con.Open();
  
  
      }
      public void conclose()
      {
          con.Close();
      }
  </code></pre>
  
  <p>i have read that there is trust level , but i ma unable to use that every time i open the webpage on online server int gave me the same error </p>