BPGridView, MySql plugin

MySql data source plugin for the BPGridView package.

Using MySql Connector/Net, MySql.Data.dll v. 5.1.1.1.

The package only consists of two dll's.

Modify it any way you like. The source code is here:

 

using System;
using System.Data;
using MySql.Data.MySqlClient;
using System.Web.UI.WebControls;

namespace BP.Umb.DataSourcePlugin
{

    public class MySqlPlugin : IDataSourcePlugin
    {
        public MySqlPlugin()
        {
        }

        // The single point of entry to our plugin
        // Accepts an IPluginContext object which holds the current context.
        public void PerformAction(IDataSourcePluginContext context)
        {
            context.DataSource = CreateDataSource(context);
        }

        // Create the data source
        private DataTable CreateDataSource(IDataSourcePluginContext context)
        {
            MySqlConnection myConnection = new MySqlConnection(context.ConnectionString);
            MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(context.QueryString, myConnection);
            DataTable myDataTable = new DataTable();
            myDataAdapter.Fill(myDataTable);
            return myDataTable;
        }
    }

}

The IDataSourcePlugin is defined within the BP.Umb.DataSourcePlugin namespace in the BPGridView dll:

using System;
using System.Data;
using System.Runtime.InteropServices;
using System.Web.UI.WebControls;

namespace BP.Umb.DataSourcePlugin
{
    [GuidAttribute("3ce6edc1-be6e-4a80-aabb-3368dd813841")]
    public interface IDataSourcePlugin
    {
        void PerformAction(IDataSourcePluginContext context);
    }

    public interface IDataSourcePluginContext
    {
        string ConnectionString { get; set; }
        string QueryString { get; set; }
        DataTable DataSource { get; set; }
    }
}