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

Telerik SQLDatasource with params

4 Answers 410 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Geoff
Top achievements
Rank 1
Iron
Geoff asked on 22 Sep 2017, 01:44 PM

Hi there,

My scenario is this....

Report 1: Has a sqldatasource which calls a stored procedure which takes in 2 parameters.

Report 2: Has a sqldatasource which calls a different stored procedure but takes in exactly the same 2 parameters.

Report 1 contains summary information. Report 2 contains detailed information.

I need to combine the reports. Therefore my thinking is that Report 1 will be the master and Report 2 will be the sub.

My question is: how can i pass the datasource params from Report 1 (Master) to the Report 2 (Sub)?

Any help greatly appreciated.

 

4 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 26 Sep 2017, 01:28 PM
Hello Geoff,

I assume that you use a Master Report with a SubReport item which source is the Sub Report.
It is possible to pass the sqlDataSource parameters between the two datasources using  ReportParameters. You can follow these steps:
  • create two ReportParameters in the Sub Report that correspond to the two store procedure parameters
  • set the Sub Report sqlDataSource parameters values to correspond to the values of the Sub Report ReportParameters
  • create the same ReportParameters in the Master Report
  • from SubReport item ReportSource Property choose Edit Paremeters and set the Parameter Name to the corresponding Sub Report ReportParameter, and Parameter Value to the corresponding ReportParameter (or data field value) of the Master Report
  • set the values of Master sqlDataSource paremeters to correspond to the Master Report ReportParameters (and thus to the Sub Report sqlDataSource parameters)
 I hope this would help. Let us know if you need more assistance.

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
0
Geoff
Top achievements
Rank 1
Iron
answered on 26 Sep 2017, 04:24 PM

Thank you very much Todor - that worked.

One final question....

When we run the reports programmaticly I set the the Master Report data source and parameter value using....

  Dim rep = TryCast(Activator.CreateInstance(Reflection.Assembly.Load("IFMReportLibrary").GetType("IFMReportLibrary.VINSByDriver")), Report)

        TryCast(rep.DataSource, Telerik.Reporting.SqlDataSource).Parameters.RemoveAt(0)
        TryCast(rep.DataSource, Telerik.Reporting.SqlDataSource).Parameters.Add(New SqlDataSourceParameter("@inspectionID", SqlDbType.Int, CInt(listInspections.SelectedValue)))

 

Which works correctly.

Now I am trying to do the same for the sub report using....

  Dim sReport As Telerik.Reporting.SubReport = TryCast(rep.Items.Find("SubReport1", True)(0), Telerik.Reporting.SubReport)
        'sReport.ReportSource.Parameters.Add(New SqlDataSourceParameter("@inspectionID", SqlDbType.Int, CInt(listInspections.SelectedValue))

        TryCast(sReport.Report.DataSource, Telerik.Reporting.SqlDataSource).Parameters.RemoveAt(0)
        TryCast(sReport.Report.DataSource, Telerik.Reporting.SqlDataSource).Parameters.Add(New SqlDataSourceParameter("@inspectionID", SqlDbType.Int, CInt(listInspections.SelectedValue)))

But this does not work.

Can you help?

0
Todor
Telerik team
answered on 27 Sep 2017, 08:59 AM
Hello Geoff,

In the provided code sample the SubReport item (sReport) is an item in the main report, and sReport.Report is actually its parent/main report.
Note that the sub report would be specified in sReport.ReportSource. This sub report should then be updated with the parameters or datasource.
I would refer you to the API of the SubReport class.

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
0
Geoff
Top achievements
Rank 1
Iron
answered on 27 Sep 2017, 12:10 PM

Todor - thank you very much - the information you provided enabled me to understand where I was going wrong.

Everything now working so again thank you for your help it is much appreciated.

All the best

Geoff

Tags
General Discussions
Asked by
Geoff
Top achievements
Rank 1
Iron
Answers by
Todor
Telerik team
Geoff
Top achievements
Rank 1
Iron
Share this question
or