Back to Devexpress

Restore Data Connections in Blazor Report Viewer

xtrareports-405563-web-reporting-blazor-reporting-native-report-viewer-restore-data-connections.md

latest2.0 KB
Original Source

Restore Data Connections in Blazor Report Viewer

  • Feb 09, 2026
  • 3 minutes to read

When you load reports from REPX files, the file may contain a connection string name. In this case, the Report Viewer attempts to create a connection string using this connection string name and retrieve data. You need to implement a service that resolves a connection name to a valid connection.

SQL Data Sources

To create this service for SQL data connections, implement the IConnectionProviderFactory service that creates the IConnectionProviderService service. The IConnectionProviderService service retrieves a connection string from the application configuration file and returns the string to the Report Viewer.

Follow the steps below:

  1. Add a connection string to the appsettings.json file:

  2. Create the DataConnectionService.cs file in the Services folder with the following code that implements the services:

  3. Register the IConnectionProviderFactory and IConnectionProviderService services at application startup:

JSON Data Sources

To create such a service for JSON data connections, implement the IJsonDataConnectionProviderFactory service that creates the IJsonDataConnectionProviderService service. The IConnectionProviderService service retrieves a connection string from the application configuration file and returns the string to the Report Viewer.

Follow the steps below:

  1. Add a connection string to the appsettings.json file:

  2. Create the DataConnectionService.cs file in the Services folder with the following code that implements the services:

  3. Register the IConnectionProviderFactory and IConnectionProviderService services at application startup: