title: Grid View Error Visual Studio 2010 asp.NET Framework 4. Unable to find .NET Framework Provider
body: <p>I have an SQL Compact edition database as a local file. I'm using Visual Studio 2010 to access the database and make my asp.NET website.</p>
  
  <p>In my aspx page design view, the data displays fine, and when I configure it and run a test query, it works fine... </p>
  
  <p>However When I run my page I get this strange Error.</p>
  
  <pre><code>Unable to find the requested .Net Framework Data Provider.  It may not be installed.
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.
  
  Source Error: 
  
  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
  
  Stack Trace:
  
  [ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.]
      System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1402071
      System.Web.UI.WebControls.SqlDataSource.GetDbProviderFactory() +67
      System.Web.UI.WebControls.SqlDataSource.GetDbProviderFactorySecure() +22
      System.Web.UI.WebControls.SqlDataSource.CreateConnection(String connectionString) +11
      System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +117
      System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
      System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
      System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
      System.Web.UI.WebControls.GridView.DataBind() +4
      System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +66
      System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
      System.Web.UI.Control.EnsureChildControls() +102
      System.Web.UI.Control.PreRenderRecursiveInternal() +42
      System.Web.UI.Control.PreRenderRecursiveInternal() +175
      System.Web.UI.Control.PreRenderRecursiveInternal() +175
      System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
  </code></pre>
  
  <p>I for one, have no idea what this is... I have scoured the net and found that it MAY have something to do with my web.config file. My aspx code is:</p>
  
  <pre><code>&lt;asp:SqlDataSource ID="pending" runat="server"
      ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;"                
  
      SelectCommand="SELECT u.firstName, u.surname, w.url, c.companyName, o.cost FROM Website AS w INNER JOIN Orders AS o ON w.webID = o.websiteID INNER JOIN Company AS c ON w.companyID = c.companyID INNER JOIN Users AS u ON c.userID = u.userID WHERE (o.completed = 'N')" 
      ProviderName="&lt;%$ ConnectionStrings:ConnectionString.ProviderName %&gt;"&gt;
  &lt;/asp:SqlDataSource&gt;
  
  &lt;asp:GridView ID="grid" runat="server" AutoGenerateColumns="False" 
      &lt;Columns&gt;
          &lt;asp:CommandField ShowSelectButton="True" /&gt;
          &lt;asp:BoundField DataField="firstName" HeaderText="firstName" ReadOnly="True" 
              SortExpression="firstName" /&gt;
          &lt;asp:BoundField DataField="surname" HeaderText="surname" ReadOnly="True" 
              SortExpression="surname" /&gt;
          &lt;asp:BoundField DataField="url" HeaderText="url" ReadOnly="True" 
              SortExpression="url" /&gt;
          &lt;asp:BoundField DataField="companyName" HeaderText="companyName" 
              ReadOnly="True" SortExpression="companyName" /&gt;
          &lt;asp:BoundField DataField="cost" HeaderText="cost" ReadOnly="True" 
              SortExpression="cost" /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>And my web config is:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  &lt;connectionStrings&gt;
          &lt;add name="ConnectionString" connectionString="Data Source=Database.sdf;Password=XXXX;Persist Security Info=True"
              providerName="Microsoft.SqlServerCe.Client.3.5" /&gt;
      &lt;/connectionStrings&gt;
      &lt;system.web&gt;
          &lt;compilation debug="true" targetFramework="4.0"&gt;
          &lt;assemblies&gt;
              &lt;add assembly="Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;
              &lt;/assemblies&gt;
          &lt;/compilation&gt;
          &lt;authorization&gt;
              &lt;deny users="?" /&gt;
          &lt;/authorization&gt;
      &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Sorry for the LONG Post... But I really cant see the problem and i wont waste another 2 hours of my life trying to fix this!</p>
  
  <p>Thank you!</p>
  
  <p>Basically my site runs fine without the GridView. As soon as I add it, the web browser appears with that error.</p>
  
  <p>Ive added the Microsoft.SqlServerCe.Client factory in the config...Still nothing</p>