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

Changing connection string dynamically in telerik reports

1 Answer 2232 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dinu
Top achievements
Rank 1
Dinu asked on 22 Aug 2019, 05:51 AM

We have some reports in which we have added two sqlDatasources in that. One for header data and other for the details. In theses SqlDatasources we have given one connection string which is given in web.config and app.config. We have to change the connection string (we need to connect to different databases according to the user) dynamically. How can we implement it in Telerik reports?

We are calling the report using an ASP.Net MVC project. 

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 26 Aug 2019, 12:35 PM
Hello Dinu,

The recommended approach for setting the connection string dynamically is through dedicated Report Parameter. You may use the given approach from Change Connection String dynamically through a report parameter KB article when it is necessary to modify the connection string run-time. The value of the Report Parameter can be passed from the viewer at run-time and will be automatically assigned to the DataSource when processing the report. 

Another option is to apply the approach from Changing the connection string dynamically according to runtime data KB article. Generally we do not recommend this approach as it requires additional programming and is more difficult to maintain, especially when there are changes in the Reporting API. The modifications should be made in the Resolve() method of a Custom Report Resolver. Sample code and further details can be found in Action NavigateToReport does not work after updating the Connection String dynamically in a Custom Report Resolver KB article. 
 
Regards,
Neli
Progress 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
Dinu
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or