Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8950

Re: Setting data source for subreports that are added during run-time to main report

$
0
0

Hi, there.

 

Thank you for the comment

 

Hope these update will be of same level of interest to you.

 

I still haven't succeeded in using separate datasets, or even strongly typed data set for my current solution.

 

I've read the wiki, but, no success. Only thing I've realized as the difference when one passes strongly typed dataset opposed to a plain DataSet, filled  with correct data, of course, is that in the XML schema in the main node, we have a name of the data set, and path to xsd file that presents its definition (i.e. <ReportsDataSet xmlns="http://tempuri.org/ReportsDataSet.xsd">) . With DataSet, main node is just <NewDataSet>.

 

Everything else seems the same.

 

Also, I have been reading over and over your answers to this discussion, and maybe the problem lies in the details. I see that still I do not quite understand how to load each subreport as an independent report, and then gather all together in one main, as you have suggested to me.

             

              1.*** Best way to troubleshoot these issues is to break up the report - save out the subreports and runt he subreports as their own reports, passing the dataset to them. Once this works, use the origianl report with the subreports, passing them the correct dataset. 

               2.***

You could I suppose even have a mutitable dataset for the main report as well as teh subreports, but then you'd have to tell the subreport which table9s) to use. E.g.; rather than:

boReportDocument.SetDataSource(oDataSet);

which would try to inhale everything from the DS, do:

boTable.SetDataSource(oDataSet.Tables[tableName]);

 

My code now has one CommonDataSet with 3 Tables - MainReportTable, Subreport1Table, Subreport2Table.

Also, I have 3 separate Crystal reports files: MainReport.rpt file ( this one is created to look into MainReportTable as datasource by using Report Wizard, during creation), and SubReport1. rpt (uses table Subreport1Table) and SubReport2.rpt file (uses Subreport2Table).

 

 

When I come to process of generating a report, lets say, that consists of, of course, MainReport that gets injected  Subreport1 in his first detail section, I use following code:

 

               // vars

               CrystalDecisions.CrystalReports.Engine.ReportDocument document = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

               ReportDefModel.Section section;

               Controllers. SubreportClientDocument subreportClientDocument;

               ClientDoc.ISCDReportClientDocument reportClientDocument;

         

               // init

                 DataSet reportDataSet = new DataSet();

 

                 document.Load(MainReportFullFilePath);

 

                 reportClientDocument = document.ReportClientDocument;

 

                 section = reportClientDocument.ReportDefController.ReportDefinition.DetailArea.Sections[0];

             

                subreportClientDocument = reportClientDocument.SubreportController.ImportSubreport(subReport1Name, subreport1FullFilePath, section);

              

                   // fill data

                reportDataSet.Tables.AddRange(someProvider.GetReportDataTables(subreport1); //this returns tables filled with correct data; they have                     //correct structure, but are not strongly typed- returned as List<DataTable>

                 

                 reportDataSet.Tables.AddRange(someProvidet.GetReportDataTables(mainReport); //get the data for the main report table as well

         

                  // connect with report

          document.SetDataSource(reportDataSet);  //finally, dataset with added both tables, that are both filled with data, gets set as data source, for                     //the main report.

 

 

As you can see from this, I only know how to load a subreport by using ImportSubreport, and then set entire dataset to the entire main report.

 

How can I achieve creating of subreport document, setting datasource, and then doing the same for the main, and assemble all together?

 

Thank you sooo much for any help. It means the world to me!

 

- Jelena


Viewing all articles
Browse latest Browse all 8950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>