MarcoMySql DataProvider
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><br /> <DbProviderFactories><br /> <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" /><br /> </DbProviderFactories><br /></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;"<br />ProviderName="MySql.Data.MySqlClient" SelectCommand="select ID, Name, Address from Customer"<br />InsertCommand="INSERT INTO customer VALUES(null, ?name, ?address)" <br />DeleteCommand="DELETE FROM customer WHERE ID = ?ID "<br />UpdateCommand="UPDATE customer SET name=?name, address=?address WHERE ID = ?ID;"><br /> <InsertParameters><br /> <asp:ControlParameter ControlID="TextBoxName" ConvertEmptyStringToNull="true" Name="name" /><br /> <asp:ControlParameter ControlID="TextBoxAddress" ConvertEmptyStringToNull="true" Name="address" /><br /> </InsertParameters><br /></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><br /> <DbProviderFactories><br /> <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" /><br /> </DbProviderFactories><br /></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;"<br />ProviderName="MySql.Data.MySqlClient" SelectCommand="select ID, Name, Address from Customer"<br />InsertCommand="INSERT INTO customer VALUES(null, ?name, ?address)" <br />DeleteCommand="DELETE FROM customer WHERE ID = ?ID "<br />UpdateCommand="UPDATE customer SET name=?name, address=?address WHERE ID = ?ID;"><br /> <InsertParameters><br /> <asp:ControlParameter ControlID="TextBoxName" ConvertEmptyStringToNull="true" Name="name" /><br /> <asp:ControlParameter ControlID="TextBoxAddress" ConvertEmptyStringToNull="true" Name="address" /><br /> </InsertParameters><br /></asp:SqlDataSource>
You can freely download the source and the assembly here.
Commenti
MarcoMySql DataProvider
Per inserire un commento, devi avere un account.
Fai il login e torna a questa pagina, oppure registrati alla nostra community.
Collegamenti sponsorizzati
- Sciopero negli anni '50: il ricordo di Francesco Floris "Chiccheddu", classe 1923
- Povera Bari, città vituperata per colpa di alcuni ingrati figli
- Miniere di platino a Napoli: tutto merito (e anche colpa) della benzina verde
- Comunicato stampa - Sysdata Italia (gruppo Datamat) aderisce al programma TIBCO Alliance Partner
- Comunicato stampa - Sinapsi: partnership con Sun Microsystems e I.Net
Approfondimenti
Impostare a runtime una layout page mobile su ASP.NET MVC 3
Introduzione ad ASP.NET MVC 3
Facebook e Twitter API: integrare i social network nelle applicazioni ASP.NET
ASP.NET 4.0 in practice
nopCommerce: la soluzione Open Source per il commercio elettronico
Specificare la lunghezza massima di un campo stringa con Entity Framework Code First usando Data Annotation
Reportistica in ASP.NET con la libreria Spire.DataExport
Effettuare il deploy di un'applicazione ASP.NET basata su SQL Server Compact 4.0
Le soluzioni Open Source per ASP.NET: un'alternativa allo sviluppo di applicazioni
databinding tipizzato nei template con la prossima versione di #aspnet (via @scottgu): http://aspitalia.com/zo
Real Code Day 6
Le migliori applicazioni Open Source per il web











