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
Approfondimenti
Rilasciato jQuery Mobile Beta 1
Remote validation con ASP.NET MVC 3
Uno sguardo a ASP.NET 4.5 e Visual Web Developer 11
Utilizzare SQL Server Compact 4.0 in un'applicazione ASP.NET
Integrare i social network con ASP.NET Web Pages
nopCommerce: la soluzione Open Source per il commercio elettronico
Reportistica in ASP.NET con la libreria Spire.DataExport
Migliorare il markup prodotto da CheckBoxList e RadioButtonList di ASP.NET
buon anno a tutti! ricordate di installare questa patch, per evitare attacchi di tipo DoS ad #aspnet! http://aspitalia.com/27 #security
Impedire il remote linking di immagini tramite URL Rewrite Module di IIS 7
Rilasciato il bollettino MS11-100 per risolvere i problemi di attacchi DoS di ASP.NET
Un ActionLink dal contenuto personalizzabile per ASP.NET MVC











