Configuring an MSSQL Database Storage for the Reporting REST Service
This article explains how to configure an MSSQL Database for the Reporting REST Service storage.
-
Ensure a database instance is available for Reporting REST Service storage. This may be a dedicated database or a shared database for both app data and Reporting REST Service storage.
- Start the Telerik Database Cache Configurator tool located in the {Telerik Reporting installation folder}/Tools folder.
- In Choose database usage combo-box select the "Configure REST service storage database" option.
- In Choose target backend combo-box select the "Microsoft SQL Server" option.
- In Specify connection string text box enter the connection string that references the target database. You can also click the Build button and create the connection string using the Connection properties form.
- Click on the Create schema button to start the database schema creation.
- A message box should be displayed, confirming that the storage tables are successfully created. Use the connection string specified above when initializing an instance of MsSqlServerStorage in your application.
- In case you want to cleanup the storage tables in an existing database, use the button Clear cache data.
-
Configure your Telerik Reporting REST Service to use the database storage we just prepared. You may do this in the configuration file of the project as elaborated in the article restReportService Element, or when instantiating the ReportServiceConfiguration. Here are samples for both scenarios:
-
Through code when passing ReportServiceConfiguration instance to the REST Service.
The ReportSourceResolver and Storage configuration settings are required. See the IReportServiceConfiguration interface for more details.
public class MSSqlReportsController : ReportsControllerBase { static readonly ReportServiceConfiguration configurationInstance = new ReportServiceConfiguration { HostAppId = "Application1", ReportSourceResolver = new UriReportSourceResolver(HttpContext.Current.Server.MapPath("~/Reports")) .AddFallbackResolver(new TypeReportSourceResolver()), Storage = new Telerik.Reporting.Cache.MsSqlServerStorage("Data Source=(local)\\SQLEXPRESS;Initial Catalog=RestServiceStorage;Integrated Security=SSPI"), }; public MSSqlReportsController() { this.ReportServiceConfiguration = configurationInstance; } }
Public Class MSSqlReportsController Inherits ReportsControllerBase Shared ReadOnly configurationInstance As ReportServiceConfiguration Shared Sub New() Dim resolver = New UriReportSourceResolver(HttpContext.Current.Server.MapPath("~/Reports")) _ .AddFallbackResolver(New TypeReportSourceResolver()) Dim reportServiceConfiguration As New ReportServiceConfiguration() reportServiceConfiguration.HostAppId = "Application1" reportServiceConfiguration.ReportSourceResolver = resolver reportServiceConfiguration.Storage = New Telerik.Reporting.Cache.MsSqlServerStorage("Data Source=(local)\SQLEXPRESS;Initial Catalog=RestServiceStorage;Integrated Security=SSPI") configurationInstance = reportServiceConfiguration End Sub Public Sub New() Me.ReportServiceConfiguration = configurationInstance End Sub End Class
-
Through a configuration file:
-
You need to pass a ConfigSectionReportServiceConfiguration instance to the REST Service:
public class ReportsController : ReportsControllerBase { static Telerik.Reporting.Services.ConfigSectionReportServiceConfiguration configSectionConfigurationInstance = new Telerik.Reporting.Services.ConfigSectionReportServiceConfiguration(); public ReportsController() { this.ReportServiceConfiguration = configSectionConfigurationInstance; } }
Public Class ReportsController Inherits ReportsControllerBase Shared configSectionConfigurationInstance As New Telerik.Reporting.Services.ConfigSectionReportServiceConfiguration() Public Sub New() Me.ReportServiceConfiguration = configSectionConfigurationInstance End Sub End Class
The properties from the initialization block would override the values obtained from the configuration file.
-
Set the corresponding properties values in the REST Service configuration file:
-
XML-based configuration file:
<configuration> ... <Telerik.Reporting> <restReportService hostAppId="Application1" workerCount="4" reportSharingTimeout="10" clientSessionTimeout="10" exceptionsVerbosity="detailed"> <reportResolver provider="type" /> <storage provider="MSSQLServer"> <parameters> <parameter name="connectionString" value="Data Source=(local)\SQLEXPRESS;Initial Catalog=RestServiceStorage;Integrated Security=SSPI" /> <parameter name="commandTimeout" value="60" /> </parameters> </storage> ... </restReportService> ... </Telerik.Reporting> ... </configuration>
-
JSON-based configuration file:
"telerikReporting": { "restReportService": { "hostAppId": "Application1", "reportResolver": { "provider": "type" }, "storage": { "provider": "MSSQLServer", "parameters": [ { "name": "connectionString", "value": "Data Source=(local)\SQLEXPRESS;Initial Catalog=RestServiceStorage;Integrated Security=SSPI" }, { "name": "commandTimeout", "value": 60 } ] } }, ... }
-
-
-