Pedro Costa
Pedro Costa

Reputation: 437

Unable to find the requested .Net Framework Data Provider. It may not be installed

I know there is a bunch of posts with this errors, but im not getting this one from and MVC project. I created a simple ASP.net empty web site, then added the app_Data folder, created and SQL Database, added a table and then i created a web form. Whenever i try to run the app, this errors pop. I find this really weird because i can run other ASP.NET projects, like MVC with no problems at all, and the data provider is the SAME, i double checked. Anyway, here is the info:

<connectionStrings>
    <add name="principal" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFileName=|DataDirectory|\Database.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

The database name is correct, i double checked. Plus, i have another project with the exact same connection string and it works (But it isnt asp.net forms, its an mvc project)

Info about the error :

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) +1442135
   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) +113
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
   System.Web.UI.WebControls.ListView.PerformSelect() +167
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
   System.Web.UI.WebControls.ListView.CreateChildControls() +122
   System.Web.UI.Control.EnsureChildControls() +83
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237

Upvotes: 0

Views: 918

Answers (1)

Pedro Costa
Pedro Costa

Reputation: 437

I was able to fix my problem, i don't know if this is a bug but it seems like it. I used to have this in my SQL data source:

<asp:SqlDataSource ID="MensagemSqlDataSource" runat="server"
            ConnectionString="<%$ ConnectionStrings:principal %>"
            ProviderName="<%$ ConnectionStrings:principal.ProviderName %>"
            SelectCommand="SELECT Codigo,Assunto FROM Mensagem WHERE Resposta IS NULL ORDER BY Codigo"
            DeleteCommand="DELETE FROM Mensagem WHERE Codigo = @Codigo">

//(...) doesn't matter the rest of the code (...)

So the ProviderName line was pointing to ConnectionStrings: principal.ProviderName, witch is "System.Data.SqlClient" as stated in my first post. So i just changed that to :

<asp:SqlDataSource ID="mensagemBlog"
             runat ="server" 
            ConnectionString ="<%$ ConnectionStrings:principal %>" 
            ProviderName ="System.Data.SqlClient" 
            SelectCommand ="SELECT Codigo,Assunto FROM Mensagem WHERE Resposta IS NULL ORDER BY Codigo"
            DeleteCommand="DELETE FROM Mensagem WHERE Codigo = @Codigo" >

and it worked. Maybe this is some kind of bug or i am mistaken of how about that command works.

Upvotes: 1

Related Questions