Mysql – ASP .NET – Configure SQLDataSource to use MySQL .NET Connector


I am using VS 2008.

Looking around on the forums/stack hasn't provided a clear answer on how to use MySQL with a ASP .NET site.

How do I configure a SQLDataSource to use MySQL by using the MySQL Connector NET provider?

I would prefer not to use the ODBC driver – which I can get working. The connector has been added as a reference to the project and appears in the web.config as:

<add assembly="MySql.Data, Version=, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>

And I also attempted to manually create a section under :

<add name="MYSQL" connectionString="Server=localhost;Database=data;Uid=root;Pwd=1234;" providerName="MySql.Data" />

The MySQL Connector version that I have is

Best Solution

in web.conf file, you add following lines: <connectionStrings> <add name="connMysql" connectionString ="Server=localhost;Database=transcode;Uid=root;" providerName="MySql.Data.MySqlClient"/> </connectionStrings>

in .aspx file you can add following lines:

<asp:SqlDataSource ID="Datacmd" runat="server" ConnectionString="<%$ConnectionStrings:connMysql %>" ProviderName="<%$ ConnectionStrings:connMysql.providerName%>" SelectCommand="SELECT,server.ip,,command.cmd,command.input_ip,command.output_ip,,command.status FROM server,command WHERE " </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="Datacmd" AutoGenerateColumns="False" ForeColor="#003300"> <Columns> ............................. </Columns> </asp:GridView>

Related Question