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

how to specify connection string for detail report

1 Answer 129 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
tomas
Top achievements
Rank 1
tomas asked on 22 Oct 2012, 02:25 PM
Hello TElerik,

My web application enables a user to choose database at runtime. I have a more connection strings in a web.config.

Selected connection string key is stored in a session.

I can read this key during loading a page with a report web viewer.

My main report is accepting connection string parametr using its constructor, but I dont know, how to specify this for a details subreports.

Can you advice me how to solve this?

Thank you very much.

Tom

1 Answer, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 25 Oct 2012, 01:16 PM
Hi Tom,

We would recommend to you to use Report Parameters. The Report Sources support parameters passing. Once you pass the connection string to the main report as parameter, it can easily propagate the parameter to its sub-reports (see: How-To: Creating Master-Detail Reports Using SubReports). 

In order to intercept the parameters inside the inner report (the one that serves as a sub-report), you can do the following:
  1. Attach to the ItemDataBinding event of the report
  2. In the ItemDataBinding event use the processing parameters
    private void Report1_ItemDataBinding(object sender, System.EventArgs e)
    {
        //Take the Telerik.Reporting.Processing.Report instance
        var report = (Telerik.Reporting.Processing.Report)sender;
     
        // Transfer the value of the processing instance of ReportParameter
        // to the parameter value of the sqlDataSource component
        var connectionString = report.Parameters["ConnectionStringParameter"].Value;
     
        // Set the SqlDataSource connection string
        ...
    }

Hope this helps.

Kind regards,
Elian
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
tomas
Top achievements
Rank 1
Answers by
Elian
Telerik team
Share this question
or