Multiple Subreports with a subreport passing value

2019-08-09 06:29发布

问题:

I'm using Report Viewer at C# in WinForms. I have 3 database tables: Equipament, Sector and History, I also have 3 Report.rdlc, The MAIN is the ReportEquipament and the other two subreport are ReportSector and ReportHistory. I already know how to fill the ReportSector, what I want to do is to pass the idSector from the ReportSector, so I can call a procedure at the SQL Server database and search all the History with this Sector ID, and show the data at the ReportHistory. I have no idea on how to do it. I new with ReportViewer and this is my first time doing Reports.

PS: I know how to do the procedure, just don't know how to use it.

Thanks.

Jonas.

Let me try to explain better:

I search for a specific Equipament, and that Equipament passed for many Sectors, and while he was at this sector he had problems, and this problems are related to the Sector.

What I want is something like that:

Equipament: X

Sectors: (Here the ID of the Equipament is passed to find the Sector that he has)

Sector: X (here the ID of this Sector is passed to the Subreport "Problem") Problems: (with the ID of the Sector I search all the problems at this sector) Problem: X Problem: Y

Sector: Y (here the ID of this Sector is passed to the Subreport "Problem") Problems: (with the ID of the Sector I search all the problems at this sector) Problem: X Problem: Y

回答1:

Okay after rereading you're question and understanding what you're asking here is how I have solved similar problems with SSRS. If you have the id variable at the time you load the main report (not subreports) then all you need to do is to pass that parameter into the main report and access it via the sub report.

Look here: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/92ea8f6b-ad27-42b9-a673-72ee9ce2d1fc/how-to-pass-parameters-to-ssrs-sub-reports?forum=sqlreportingservices

And here: http://technet.microsoft.com/en-us/library/ms160348(v=sql.100).aspx

If instead you need to run the main and first sub report first and then get an ID, you're most pain free way of doing this is to run one report and then have the user enter in more information to run a second report. If you really really want to make it so that can interact with the report

Look here: http://sqlserverbiblog.wordpress.com/2011/02/14/can-i-add-controls-to-a-reporting-services-report-3/



回答2:

If i am not wrong you getting problem in parameter passing in sub report. Here is the link for that