xtrareports-405563-web-reporting-blazor-reporting-native-report-viewer-restore-data-connections.md
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.
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:
Add a connection string to the appsettings.json file:
Create the DataConnectionService.cs file in the Services folder with the following code that implements the services:
Register the IConnectionProviderFactory and IConnectionProviderService services at application startup:
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:
Add a connection string to the appsettings.json file:
Create the DataConnectionService.cs file in the Services folder with the following code that implements the services:
Register the IConnectionProviderFactory and IConnectionProviderService services at application startup: