New to Telerik Reporting? Download free 30-day trial

How to Configure an MSSQL Database Storage

This article will explain how to configure an MSSQL database for report engine storage.

How to configure an MSSQL database storage:

  1. Ensure a database instance is available for report engine storage. This may be a dedicated database or a shared database for both app data and report engine storage.

    1. Start the Telerik Database Cache Configurator tool located in the {Telerik Reporting installation folder}/Tools folder.

    2. In Choose database usage combo-box select the "Configure REST service storage database" option.

    3. In Choose target backend combo-box select the "Microsoft SQL Server" option.

    4. 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.

    5. Click on the Create schema button to start the database schema creation.

    6. 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.

    7. In case you want to cleanup the storage tables in an existing database, use the button Clear cache data.

  2. 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:

      1. 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.

      2. 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
                  }
             ]
              }
            },
          ...
          }
          

See Also

In this article