Back to Devexpress

Restore Data Connections

xtrareports-405651-web-reporting-blazor-reporting-web-document-viewer-restore-data-connections.md

latest2.7 KB
Original Source

Restore Data Connections

  • 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 Document 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. The IConnectionProviderService retrieves a connection string from the application configuration file and returns the string to the Document 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. The IConnectionProviderService retrieves a connection string from the application configuration file and returns the string to the Document 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:

Object Data Sources

The report definition file (REPX file) contains the following ObjectDataSource information: the type of an object used for the object data source, the object’s property or method name used to retrieve data, and the parameters. This information is Base-64 encoded.

When the Document Viewer loads a report, it attempts to recreate the data source and use it to retrieve data. If the object that serves as the data source is not defined or referenced in your project, the attempt to recreate the data source fails. In this situation, implement a custom IReportProvider / IReportProviderAsync service that assigns a data source to the report before the Document Viewer displays it.