This article explains you how to create MySQL Data Source extension with Report Viewer.
Add BoldReports.Web reference with the application to provide the extension support for MySQL data source. For this, add the MySQL reference with the application to provide the Data Processing Extensions support.
If you are going to create separate libraries for the Data Processing Extensions, then you have to add BoldReports.Web and MySQL references with your class library.
IDataExtension interface needs to be implemented with your Data Processing Extension class to provide the extension support and IDataExtension members will be invoked from the Report Viewer.
namespace BoldReports.DataExtensions.MySQL
{
public class MySQLDataExtension : BoldReports.Data.IDataExtension
{
Data Processing Extensions TestConnection member will be invoked from Report Viewer for configured data source when Test Connection performed with Data source creation. You should write the implementation in this method to perform the connection testing of the configured data source. Implementation for 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();
}
}
Data Processing Extensions GetSchemaData member will be invoked from Report Viewer for configured data source while changing the CommandText/Query in DataSet designer. It is invoked to generate the fields for DataSet based on dataset query.
public object GetSchemaData()
{
return null;
}
Data Processing Extensions GetData member will be invoked from ReportViewer to get the data for configured data source. We should write the implementation in this method to execute the data source query and return the query result with this method.
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();
}
}
}
To configure the prepared Data Processing Extensions with Report Viewer, add the Data Processing Extensions information with following format in the application configuration,
<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>
You should add the dependent assemblies with application or it should be there in the application location.
You can use the following format, if the Data Extension prepared with Class library,
<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>
You should add the Data Processing Extensions assemblies and dependent assemblies with application or it should be there the application location.