MarcoMySql DataProvider

English version

MarcoMySql è la rifattorizzazione del Data Provider per MySql (Connector 1.0.7) al fine di implementare le classe basi contenute nel namespace System.Data.Common.

La rifattorizzazione comprende l'aggiornamento di alcune classi e l'implementazione della nuova classe factory MySqlProviderFactory (MySql.Data.MySqlClient).
La classe MySqlProviderFactory ci consente di utilizzare MySql insieme al controllo SqlDataSource.

Una volta copiata la dll nella cartella \bin\, è sufficente aggiungere nel Web.Config le seguenti righe:

<system.data>
<DbProviderFactories>
<add name="MarcoMySql Data Provider" invariant="MySql.Data.MySqlClient" description="Marco MySql Provider" type="MySql.Data.MySqlClient.MySqlProviderFactory, MarcoMySql.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</DbProviderFactories>
</system.data>

Potremo infine aggiungere ad esempio un SqlDataSource collegato ad una GridView, così configurato sulla nostra pagina, che funzionerà al 100% con MySQL, prestando particolare attenzione a impostare il nome del Provider su "MySql.Data.MySqlClient":

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Server=localhost;Uid=root;Pwd=X;Database=aspitalia;"
ProviderName="MySql.Data.MySqlClient" SelectCommand="select ID, Name, Address from Customer"
InsertCommand="INSERT INTO customer VALUES(null, ?name, ?address)"
DeleteCommand="DELETE FROM customer WHERE ID = ?ID "
UpdateCommand="UPDATE customer SET name=?name, address=?address WHERE ID = ?ID;">
<InsertParameters>
<asp:ControlParameter ControlID="TextBoxName" ConvertEmptyStringToNull="true" Name="name" />
<asp:ControlParameter ControlID="TextBoxAddress" ConvertEmptyStringToNull="true" Name="address" />
</InsertParameters>
</asp:SqlDataSource>

Si puossono scaricare direttamente sorgenti ed assembly.

English version

MarcoMySql is a MySql (Connector 1.0.7) Data Provider compliant with the new classes required by System.Data.Common and the new Factory architecture of ADO.NET.

This release includes new updated classes and a brand new MySqlProviderFactory class(MySql.Data.MySqlClient).
MySqlProviderFactory allows you to use MySql with a SqlDataSource control.

You have to deploy the file in the \bin\ directory and add this rows to your Web.Config file:

<system.data>
<DbProviderFactories>
<add name="MarcoMySql Data Provider" invariant="MySql.Data.MySqlClient" description="Marco MySql Provider" type="MySql.Data.MySqlClient.MySqlProviderFactory, MarcoMySql.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</DbProviderFactories>
</system.data>

Now you can add a SqlDataSource control bound to a GridView one, that will work the same way as using SQL Server, setting the Provider property on "MySql.Data.MySqlClient":

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Server=localhost;Uid=root;Pwd=X;Database=aspitalia;"
ProviderName="MySql.Data.MySqlClient" SelectCommand="select ID, Name, Address from Customer"
InsertCommand="INSERT INTO customer VALUES(null, ?name, ?address)"
DeleteCommand="DELETE FROM customer WHERE ID = ?ID "
UpdateCommand="UPDATE customer SET name=?name, address=?address WHERE ID = ?ID;">
<InsertParameters>
<asp:ControlParameter ControlID="TextBoxName" ConvertEmptyStringToNull="true" Name="name" />
<asp:ControlParameter ControlID="TextBoxAddress" ConvertEmptyStringToNull="true" Name="address" />
</InsertParameters>
</asp:SqlDataSource>

You can freely download the source and the assembly here.


Approfondimenti

Commenti
PadovaBoy scrive:
MarcoMySql DataProvider

Gran lavoro!Ma manca ancora qualcosina!Ho aggiunto pò di codice alla turca per permettere al "tuo" connector di funzionare anche con i parameter dell'...
giovedì 2 marzo 2006 | 31 risposte

Per inserire un commento, devi registrarti alla nostra community.