0
votes

i'm using ASP.NET + a MySql Db. I'm trying to configure a ListView so i've written:

<asp:SqlDataSource ID="dsDatiUtente" runat="server" ConnectionString="Server=12.28.136.29;Database=mydb;Uid=m111d1;Pwd=fake;Pooling=false;"
                ProviderName="MySql.Data.MySqlClient"
                SelectCommand="SELECT * FROM user WHERE idUser=@IdUser"

/>

At the beginning of my aspx page i've added

<%@ Import Namespace="MySql.Data.MySqlClient" %>

But if i click to the sqldatasource and click "Refresh Schema" i got this error:

"Unable to retrive schema.... Unable to find the requested .Net Framework data provider"

For instance, i've installed it , but i've also uninstalled old version, then installed new versions. In my project i simple copy Mysql dll into "bin" folder, then add a reference to that dll. I'm not sure is the corrected way...

I need to have the "refreshed schema" to permit vs.net to build automatically my listview ... if i can't to "auto build" listview, i have to write all code by hand, and it is a too expensive work me :(

What i'm wrong ?

Thank you!

2

2 Answers

1
votes

Does changing your code to something like this work?

Web.Config

<configuration>

 <system.data>
   <DbProviderFactories>
     <add name="MySQL Data Provider" 
       invariant="MySql.Data.MySqlClient" 
       description=".Net Framework Data Provider for MySQL" 
       type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.2.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
   </DbProviderFactories>
 </system.data>


  <connectionStrings>
    <add name="MySQL1"
    connectionString= "Server=12.28.136.29;Database=mydb;Uid=m111d1;Pwd=fake;Pooling=false;"
     providerName="MySql.Data.MySqlClient"/>    
  </connectionStrings>

ASPX Page:

<%@ Import Namespace="MySql.Data.MySqlClient" %>

 <asp:SqlDataSource ID="dsDatiUtente"   runat="server"
        ConnectionString="<%$ ConnectionStrings:MySQL1 %>"
        ProviderName="<%$ ConnectionStrings:MySQL1.ProviderName %>"
        SelectCommand="SELECT * FROM user WHERE idUser=@IdUser;"
         />
0
votes

I've solved registering mysql component into machine.config. It was an installation problem. So i've write into my machine.config this:

   <system.data>
    <DbProviderFactories>
        <clear/>
        <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
        description=".Net Framework Data Provider for MySQL"
        type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, 
         Version=6.2.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d " /> <!-- 13b67ce9e090fefa per la versione 6.3.1-->
    </DbProviderFactories>
</system.data>