Error Can't find object MySqlDataConnection

Paulo FreirePaulo Freire S??o Paulo - Brasil
edited 12:59PM in FastReport .NET
FastReportError01.jpg

My English is bad

In Designer's ok, when I view the error occurs.

thank you

Comments

  • edited 12:59PM
    Hello,

    You should register a connection in code, as described in the readme.txt file:

    3) register the dll programmatically
    - add the "FastReport.MySQL.dll" reference to your project;
    - execute the following code once at the application start:
    FastReport.Utils.RegisteredObjects.AddConnection(typeof(MySqlDataConnection));
  • Paulo FreirePaulo Freire S??o Paulo - Brasil
    edited 12:59PM
    AlexTZ wrote: »
    Hello,

    You should register a connection in code, as described in the readme.txt file:

    3) register the dll programmatically
    - add the "FastReport.MySQL.dll" reference to your project;
    - execute the following code once at the application start:
    FastReport.Utils.RegisteredObjects.AddConnection(typeof(MySqlDataConnection));


    Thank you AlexTZ
  • edited January 2025

    Change <MySqlDataConnection>....</MySqlDataConnection> To <XmlDataConnection>....</XmlDataConnection> in the report <Dictionary>....</Dictionary> field.

    My report sample is :

     <Dictionary>

    <XmlDataConnection>

      <TableDataSource Name="EMPLOYEES" DataType="System.Int32" Enabled="true">

       <Column Name="ID" DataType="System.Decimal"/>

       <Column Name="FIRST_NAME" DataType="System.String"/>

       <Column Name="LAST_NAME" DataType="System.String"/>

       <Column Name="EMAIL" DataType="System.String"/>

      </TableDataSource>

      </XmlDataConnection>

     </Dictionary>

  • Hello!

    Thank you for the example! We have tested the <Dictionary> snippet provided in the latest version of FastReport.Core 2026.2.8:

    Why a bare <XmlDataConnection> tag without any attributes will not connect to the data on its own: when calling report.Prepare() without registering the data in the code, a DataTableException occurs: EMPLOYEES: Table is not connected to the data. Register the data using the Report.RegisterData method. For an <XmlDataConnection> without RegisterData, the Name and the path to the XML file (XmlFile / ConnectionString) must be specified in the .frx file.

    If you are passing data from the application via Report.RegisterData(...) (for example, a `DataTable` or `DataSet` named “EMPLOYEES”), the `<XmlDataConnection>` wrapper is not required at all; you can place the `<TableDataSource>` directly within the root `<Dictionary>`:

    <Dictionary>
      <TableDataSource Name="EMPLOYEES" DataType="System.Int32" Enabled="true">
        <Column Name="ID" DataType="System.Decimal"/>
        <Column Name="FIRST_NAME" DataType="System.String"/>
        <Column Name="LAST_NAME" DataType="System.String"/>
        <Column Name="EMAIL" DataType="System.String"/>
      </TableDataSource>
    </Dictionary>
    

    If the report still needs to work directly with MySQL (due to the initial error ‘Can’t find object MySqlDataConnection’), there is no need to change <MySqlDataConnection> to <XmlDataConnection>; simply install the FastReport.Data.MySql package and register the connector once at application start-up (before report.Load(...)):

    FastReport.Utils.RegisteredObjects.AddConnection(typeof(FastReport.Data.MySqlDataConnection));

This discussion has been closed.