Change report datasource connection string using the report parameters

2 posts, 0 answers
  1. Coolasia
    Coolasia avatar
    19 posts
    Member since:
    Apr 2014

    Posted 02 Jun 2016 Link to this post


    I have two different projects, one for the reporting service which uses telerik REST services and other is the web appication with HTML 5 report viewer (javascript).

    As my web application is used by different clients the connection strings for each client is different so I am sending the connection string for the data source as one of the report parameter. So how do I assign this connection string to the report datasource when the report is run.

    First I tried the below code in report constructor but it did not work.

    public Quotation()
                // Required for telerik Reporting designer support
                this.sdsQuotationAmounts.ConnectionString = ReportParameters["connectionstring"].Value.ToString();
                this.sdsQuotationInfo.ConnectionString = ReportParameters["connectionstring"].Value.ToString();
                // TODO: Add any constructor code after InitializeComponent call

    If I use the custom report resolver the report parameters are not accessible, so how to solve this requests by sending the connection string as report parameters.


  2. Katia
    Katia avatar
    760 posts

    Posted 06 Jun 2016 Link to this post

    Hello Coolasia,

    Report parameters are evaluated when the data processing starts. In the report's constructor you will have only the default values of report parameters.

    Test the approach described in Changing the connection string dynamically according to runtime data KB article. The article illustrates how report's data items can be iterated and how their DataSource properties can be updated at run-time.
    This is a general approach describing how to retrieve the settings per Data item dynamically and you can modify the code according to your requirements. Note that changes are temporary and they are not saved in the original report definition.

    You can pass custom information as a string via the .ReportSource.Report option of the report viewer widget and then handle this information in the ReportsController using a custom report resolver.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top