-
Notifications
You must be signed in to change notification settings - Fork 204
MySQL Connection
Majorsilence Reporting includes built-in support for MySQL via the MySQL.NET data provider, which uses the MySql.Data connector.
The MySQL connector is included as a dependency of the engine packages — no additional NuGet package is required in your application project. The provider is registered automatically when RdlEngineConfigInit() is called.
dotnet add package Majorsilence.Reporting.RdlEngine
# or for Linux/macOS
dotnet add package Majorsilence.Reporting.RdlEngine.SkiaSharpServer=localhost;Port=3306;Database=mydb;Uid=myuser;Pwd=mypassword;
Common options:
| Option | Example | Notes |
|---|---|---|
Server |
localhost or 192.168.1.10
|
Hostname or IP |
Port |
3306 |
Default MySQL port |
Database |
mydb |
Schema/database name |
Uid |
myuser |
Username |
Pwd |
mypassword |
Password |
SslMode |
Required |
None, Preferred, Required
|
CharSet |
utf8mb4 |
Recommended for Unicode support |
ConnectionTimeout |
30 |
Seconds |
Full reference: MySql.Data connection string options
- Open the designer and click New Report (or File → New Report).
- On the Connection tab, select MySQL.NET from the provider drop-down.
- Enter the connection string and click Test Connection.
- Continue through the wizard to select tables and build the report.
Use OverwriteConnectionString on RDLParser to inject a runtime connection string:
using Majorsilence.Reporting.Rdl;
RdlEngineConfig.RdlEngineConfigInit();
var rdlp = new RDLParser(await File.ReadAllTextAsync("report.rdl"))
{
Folder = @"C:\reports",
OverwriteConnectionString = "Server=prod-db;Database=sales;Uid=app;Pwd=secret;"
};
using var report = await rdlp.Parse();
await report.RunGetData(null);See Set Connection String — Runtime for the full runtime override pattern.
To reuse an open MySqlConnection (for transaction support or connection pooling), assign it directly to the report's DataSource:
using MySql.Data.MySqlClient;
using Majorsilence.Reporting.Rdl;
RdlEngineConfig.RdlEngineConfigInit();
var rdlp = new RDLParser(await File.ReadAllTextAsync("report.rdl"));
using var report = await rdlp.Parse();
using var conn = new MySqlConnection("Server=localhost;Database=mydb;Uid=app;Pwd=secret;");
await conn.OpenAsync();
// Assign the live connection to the report's data source
report.DataSources["DataSourceName"].UserConnection = conn;
await report.RunGetData(null);The DataSource name must match the one defined in the report's dataset properties.
"Data provider not found" or empty results
- Confirm
RdlEngineConfig.RdlEngineConfigInit()was called before parsing. - Verify
MySql.Data.dllis present in the output directory. If using a trimmed publish, ensure the assembly is not trimmed away.
Authentication errors
- MySQL 8.0+ defaults to
caching_sha2_passwordauthentication. IfMySql.Dataversion is old, it may not support this. AddAllowPublicKeyRetrieval=Trueto the connection string, or upgrade to a newerMySql.Datapackage.
SSL errors
- Add
SslMode=Noneto the connection string for local development, or configure a proper SSL certificate for production.