Changing connection string dynamically in telerik reports

2 posts, 0 answers
  1. Dinu
    Dinu avatar
    1 posts
    Member since:
    Feb 2019

    Posted 22 Aug Link to this post

    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. 

  2. Neli
    Admin
    Neli avatar
    190 posts

    Posted 26 Aug Link to this post

    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
Back to Top