Skip to content
Report-Designer

Connect to data

Set up a SQL Server, MySQL or MariaDB connection and choose a stored procedure.

Add a connection

In Design, find Data source on the left. Click Choose for a report without a procedure or Change for one that already has one. Click Manage connections beside Connection, then click New connection in the Connections dialog.

For SQL Server, enter a name, server and database. To use the sample database on LocalDB, name the connection Sales, use server (localdb)MSSQLLocalDB and database ReportDesignerSample. Run these commands from the repository root.

sqlcmd -S "(localdb)MSSQLLocalDB" -Q "CREATE DATABASE ReportDesignerSample"
sqlcmd -S "(localdb)MSSQLLocalDB" -d ReportDesignerSample -i samples/Database/sales-summary.sql

For MySQL or MariaDB, select MySQL and enter the server, port (usually 3306), database, user and password.

Click Test connection to check the settings, then Save connection and Done. In Data source, choose the saved connection and select a procedure from the list on the left. The designer reads its parameters and fields. If it needs to run the procedure to read the columns, fill in the parameter values and click Run it to read the columns. Click Use this procedure.

To discover MySQL result columns, the designer runs the procedure with NULL parameters in a transaction and rolls it back. If that fails, it asks for parameter values. Changes to non-transactional tables such as MyISAM and changes made by DDL can persist after rollback.

Use the same connection name in your app

The desktop designer saves connections for your Windows account and encrypts their passwords. A report file stores only the connection name. Set that same name in the app or server configuration with the connection string for that deployment.

MySQL strings with options such as Port or SslMode can be detected automatically. Use DatabaseConnections.MySql(...) from ReportDesigner.Data to identify an ambiguous string explicitly.

options.Connections["Sales"] = DatabaseConnections.MySql(builder.Configuration.GetConnectionString("Sales")!);

See the setup for ASP.NET Core or ASP.NET MVC 5.