Create a MySQL Data Processing Extension for Report Viewer

To create a MySQL data processing extension for the Bold Reports® JavaScript Report Viewer, implement the IDataExtension interface in a class and register the extension in the application configuration.

How do I configure the dependent assemblies?

To configure the dependent assemblies for the MySQL data processing extension, add the BoldReports.Web reference and the MySQL reference to the application. The references provide the extension support for the MySQL data source in the Report Viewer.

If you create separate libraries for the data processing extensions, add the BoldReports.Web and MySQL references to your class library.

How do I implement the data processing extension?

To implement the MySQL data processing extension, implement the IDataExtension interface in your data processing extension class. The Report Viewer invokes the IDataExtension members.

namespace BoldReports.DataExtensions.MySQL
{
    public class MySQLDataExtension : BoldReports.Data.IDataExtension
    {

TestConnection

The Report Viewer invokes the TestConnection member of the data processing extension for the configured data source when you test the connection during data source creation. Write the implementation in this method to test the connection of the configured data source. The following code shows the implementation for the MySQL data processing extension.

public bool TestConnection(string connectionString)
{
    MySqlConnection connection = new MySqlConnection(connectionString);
    try
    {
        connection.Open();
        return true;
    }
    catch
    {
        return false;
    }
    finally
    {
         connection.Close();
         connection.Dispose();
    }
}

GetSchemaData

The Report Viewer invokes the GetSchemaData member of the data processing extension for the configured data source when the CommandText or query changes in the DataSet designer. The member generates the fields for the DataSet based on the dataset query.

public object GetSchemaData()
{
    return null;
}

GetData

The Report Viewer invokes the GetData member of the data processing extension to get the data for the configured data source. Write the implementation in this method to run the data source query and return the query result.

public object GetData()
{
   var connectionString = this.GetConnectionString();
   using (MySqlConnection connection = new MySqlConnection(connectionString))
   {
       try
       {
            connection.Open();
            DataTable dataTable = this.GetTable(connection, this.CommandText);
            return dataTable;
       }
       catch (Exception ex)
       {
            throw ex;
       }
       finally
       {
            connection.Close();
            connection.Dispose();
       }
   }
}

How do I deploy the data processing extension in the Report Viewer?

To deploy the MySQL data processing extension in the JavaScript Report Viewer, register the extension in the application configuration, as described in the following sections.

How do I configure the data processing extension?

To configure the data processing extension with the Report Viewer, add the extension information to the application configuration in the following format.

  <configSections>
      <section name="ReportingExtensions" type="BoldReports.Configuration.Extensions, BoldReports.Web" allowLocation="true" allowDefinition="Everywhere" />
  </configSections>

  <ReportingExtensions>
    <DataExtensions>
<Extension Name="MySQL" Assembly="BoldReports.DataExtensions.MySQL" Type="BoldReports.DataExtensions.MySQL.MySQLDataExtension"/>
    </DataExtensions>
  </ReportingExtensions>

Add the dependent assemblies to the application, or make sure they are in the application location.

How do I configure an extension built as a class library?

If you built the MySQL data extension as a class library, use the following format in the Report Viewer application configuration.

  <configSections>
      <section name="ReportingExtensions" type="BoldReports.Configuration.Extensions, BoldReports.Web" allowLocation="true" allowDefinition="Everywhere" />
  </configSections>

  <ReportingExtensions>
   <DataExtension>
<Extension Name="MySQL" Assembly="BoldReports.DataExtensions.MySQL" Type="BoldReports.DataExtensions.MySQL.MySQLDataExtension"/>
    </DataExtension>
  </ReportingExtensions>

Add the data processing extension assemblies and dependent assemblies to the application, or make sure they are in the application location.

Download the MySQL Data Processing Extensions sample