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

Telerik.ReportViewer.Html5.WebForms.ReportViewer and run-time connection string - how to?

1 Answer 298 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 07 Dec 2018, 06:38 PM

ReportViewer has property of the type ReportSource, which does not have connectionstring property, but has parameters

How can I set connection string in runtime for the report that ReportViewer shows?

C# sample will be much appreciated.

Thanks!

 

 

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 12 Dec 2018, 11:56 AM
Hi Michael,

I have answered the questions raised here in the support ticket you opened on the same topic. For the benefit of our community I will summarize the relevant information also here.

The suggested approach for modifying DataSource connection string run time is to introduce a new Report Parameter in the report definition and assign the value of this parameter to the DataSource.ConnectionString property as explained in the Change Connection String dynamically through a report parameter KB article. The value of the Report Parameter can be passed from the viewer run time, and will be automatically assigned to the DataSource when processing the report.

The Html5 Web Report Viewers exposes a ReportSource that is a client side Report Source, which is different from server side Report Source.
The Html5 Report Viewer client side Report Source has two properties - report and parameters. The report is a string passed to the Report Resolver Resolve() method. The latter should be able to resolve this string to a valid server side Report Source. The values of the parameters in the parameters collection are automatically assigned to the Report Parameters with the same names. Note that client side Report Source properties vary according to the exact Html5 Web Viewer used (i.e. pure, MVC wrapper, Web Forms wrapper and Angular wrapper).

An alternative approach for changing connections string dynamically that is suitable (although we do *not* recommend it) for Html5 Viewer can be found in Action NavigateToReport does not work after updating the Connection String dynamically in a Custom Report Resolver KB article. The ReportConnectionStringManager should be used in the Resolve() method of a Custom Report Resolver.

Regards,
Todor
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
Michael
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or