This is a migrated thread and some comments may be shown as answers.

Change report datasource connection string using the report parameters

1 Answer 469 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Coolasia
Top achievements
Rank 1
Coolasia asked on 02 Jun 2016, 01:56 PM

Hi,

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
            //
            InitializeComponent();
            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.

Thanks

1 Answer, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 06 Jun 2016, 02:42 PM
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.


Regards,
Katia
Telerik
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
Tags
General Discussions
Asked by
Coolasia
Top achievements
Rank 1
Answers by
Katia
Telerik team
Share this question
or