Microsoft VS2012 Report with sub-report working in Dev but not live

2.5k Views Asked by At

A windows application that I wrote some years ago required some changes recently (originally written in VS2005, modified using VS2008, and now updated/modified as a VS2012 project).

The application contains a Microsoft report that contains two sub-reports. The sub report data is a dataset, populated during a ReportViewer1.LocalReport.SubreportProcessing event.

A new field was added to the main report, but the sub-reports were not modified. The report works as expected on the development PC, but when installed on the client laptop, the sub-reports fail with the message:- Data retrieval failed for the sub-report, <report name>, located at <report...rdlc>. Please check the log files for more information

No log files are produced on the client laptop

I tried to manually install the CTP 2012 Microsoft Report viewer, but the install fails, reporting that a newer version is already present (possibly from SQL Server Express 2012, also installed at the same time).

The database used for testing is restored from a live backup, so the data is the same. The sub-report event that adds the ReportDataSource to the sub-reports contains a try-catch block which doesn't raise any exceptions

During development, when I opened the reports in VS2012, a dialog opened that asked if they should be updated to the 2012 format, which I allowed, althoug this probably has no bearing on the fault.

Has anyone come across this issue? Is there a way to force the physical output of a log file on the client laptop?

UPDATE

Putting some MessagesBoxes in the code I have found the reason that sub-reports do not process, but I now need to find out why.

The 'LocalReport_SubreportProcessing' event fires twice for my report - once for each sub-report.

In order to identify which sub-report needs the additional data source, I check the value of 'SubreportProcessingEventArgs.ReportPath'. In my dev system it has the name of the report (minus the .rdlc extension) but, on the client laptop the value is empty.

I can't see how the reports get built into the output. Tthe main report shows OK on the laptop (just missing the sub-reports), although from where it is displayed I don't know at present - more investigation required!

1

There are 1 best solutions below

0
On

I have just stumbled upon the same problem. Don't you hate Microsoft sometimes for doing it to us?

Anyway I think that the best solution is to check SubreportProcessingEventArgs.DataSourceNames[0] instead of checking SubreportProcessingEventArgs.ReportPath. This will (I checked) have the name of the data source for the subreport.

If you name your datasources uniquely you can identify which subreport is calling an event and set the data source properly. I usualy name my data sources as {SubreportName}DataSet, so all my data source names have the subreport name in them. Good luck.