Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Crystal Report Problem with sub reports Post Reply Post New Topic
Author Message
Wayne69
Newbie
Newbie
Avatar

Joined: 27 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote Wayne69 Replybullet Topic: Crystal Report Problem with sub reports
    Posted: 27 Nov 2009 at 4:01am

I have a Crystal Report that has a main report and 8 sub reports.

The main report contains one record per employee, and each of the sub reports displays information about different data pertinent to the employee, e.g. cars, loans, medical benefits, etc. Each sub report may have zero – many records.

 

The application that runs this report is supplied to a variety of customers. These customers may have MS SQL Server or Oracle databases.

 

The Crystal Report is invoked via a VB.NET program. The program reads all the data required from the database into a dataset. The data is passed to the report using  ReportDocument.SetDataSource for the main report table and ReportDocument.SubReports.Item(“xxx”).SetDataSource for each of the sub reports.

 

Each of the datatables is described using an XSD, for the main report data and each of the sub report’s data. The Crystal Report uses these XSDs to describe the data and create the report fields.

 

The main datatable has approximately 25,000 records.

Subreport 1 has approximately 31,000 records.

Subreport 2 has 5,000 records.

Subreport 3 has 2,500 records.

Subreport 4 has 0 records.

Subreport 5 has 30,000 records.

Subreport 6 has 2,500 records.

Subreport 7 has 1,000 records.

Subreport 8 has 1 record.

 

These numbers may be higher in future. The more data records that the sub reports return makes the report exponentially slower.

 

When we are dealing with smaller amounts of data :- eg. Maximum of 1,000 records for each, then the report runs through in a few minutes. With the data as described above it was running for 2days and it still didn’t finish! Obviously NOT ideal for the customer.

 

As a test I have tried to using OLE DB to access the database direct, so that I could use ADD SQL Command to select the data for each subreport, but I could not find any way of reducing the number of records selected. It would dramatically reduce the time of the report if I could pass a “Value” from the main report into the Command SQL in each of the subreports, so that in the WHERE clause it has EMP_ID = {passed in EMP_ID} from the main report. This EMP_ID changes for each of the 25,000 employees in the main report. It seems that you can pass in a fixed parameter and not a dynamically changing one. Don’t know too much about SQL Expressions and whether or not they may be of any use.

 

Obviously I would like to keep the report as it is with regards to using ADO.NET, just with some magical workaround to speed up the report.

 

I have spent days googling for possible solutions and none have yet to be suitable, obviously avoiding sub reports is a good answer, and I have avoided them in the other reports and they run very quickly, but unfortunately this report cannot be written without using them as far as I can tell.

 

Any help on this would be greatly appreciated as I have no more ideas left to try.

 

Regards,

 

Wayne.
Sharing is not just for Xmas ...
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 03 Dec 2009 at 11:46am
I don't know for sure if this will work, but it's worth a try:
 
- Set up a subreport link based on Emp_ID from the main report.
- Delete the link from the Select Expert but leave the parameter in the report itself.
- Get the name of the parameter within the subreport.
- In your SQL, use the parameter from above in you where clause.  The format will look something like this:  {?pm-Emp_ID}. 
- In your code, see if there's a way to make sure that the parameter object (without a value!) has been set up.  This will be a parameter on the command, not necessarily on the subreport itself.  It needs to have the same name as the param created in the subreport link.
 
I don't know for sure if this will work as I've not tried it, but I think it will.
 
If it doesn't, is there a way to have the subreport access the tables directly instead of through a command?
 
-Dell
IP IP Logged
Wayne69
Newbie
Newbie
Avatar

Joined: 27 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote Wayne69 Replybullet Posted: 04 Dec 2009 at 2:21am
Thanks for your suggestion hilfy, I've tried this, but unfortunately it doesn't recognise the deleted link parameter as a parameter that's available. I have now managed to get round the problem and the report with 90,000 lines of data - 25,000 employees / pages now runs in 2 minutes. Basically I merge the 9 data tables into a single dataview with various keys and line numbers to aid the report formatting, and then report off that. Thus I have removed the 8 sub-reports! Sub-reports + large volumes of data = running for days :-(
 
I have then had to do all sorts of clever formatting in the report using formula and 100's of overlaying fields in the detail section to immitate sub report behaviour. But I'm sure the customers will be very pleased with the new fast report run times.
 
Regards,
 
Wayne.
Sharing is not just for Xmas ...
IP IP Logged
urielgolab
Newbie
Newbie


Joined: 14 Nov 2012
Location: Argentina
Online Status: Offline
Posts: 3
Quote urielgolab Replybullet Posted: 14 Nov 2012 at 8:22am
Hi everyone.
I've googled a post talking about supressing subreports from a very large report, witch is im currently working in and it dropped me here.

Subreports cost a lot of rendering time and my application does not allow that long waiting.

I've tested processing time while supressing subreports and the results were very acceptable.

I would like to ask how did you make possible formatting subreports to show different colums and rows into a single column and row.

I hope you still remember how you do it and keep the same email as your post dates 2009 haha.

Thanks at all.

Uriel.

Edited by urielgolab - 14 Nov 2012 at 8:23am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 14 Nov 2012 at 11:16am
What are you specifically trying to do with a subreport?  With that information I may be able to point you to a better solution.  I'll use a subreport when I need it, but I try to avoid them if I can.
 
The thing to remember about subreports is that every time they are called, they create a separate connection to the database and run a query.  This means that if you put the subreport in a details section, it will connect to the database and run a query for every record displayed on the report.  So, if you're trying to get detail data, you'll need to come up with a different way of doing it.  Or, if the query in your subreport doesn't push the filter down to the database (this happens when you use Crystal functions in your selection criteria or for a couple of other reasons) then it will bring ALL of the data in to the subreport and filter it in memory.  Either one of these situations will significantly increase the report runtime.
 
-Dell
IP IP Logged
urielgolab
Newbie
Newbie


Joined: 14 Nov 2012
Location: Argentina
Online Status: Offline
Posts: 3
Quote urielgolab Replybullet Posted: 15 Nov 2012 at 2:33am
Thanks you very much for your quick answer Dell.

I actually have a .NET DataSet representing a few stored procedures that filled datatables with a few thousands of records within the application.

Im trying to generate the invoices based on the principal table (ex Invoice), witch contains headers and are linked to other tables (ex Invoice_Details) through Subreports. (database information is retrieved quickly but im not sure if Crystal uses indexes to arrange and link subrepots).
Also, the root report (Invoices) is grouped by idInvoice because a document contain many invoices.

I have 8 subreports based on hierarchy of the reports.

I do know that suppressing subreports will reduce the processing time but would not be the natural way as i understand things.

I've uploaded an image with the report im working in:

(hope you understand Spanish as i try to do with English haha).

Thank you again.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 15 Nov 2012 at 3:16am
Have you tried just linking the tables together in the main report instead of using subreports?  In particular, I would look at doing that for the subreport that's in your details section, as this is the one that would significantly slow down your report.
 
-Dell
IP IP Logged
urielgolab
Newbie
Newbie


Joined: 14 Nov 2012
Location: Argentina
Online Status: Offline
Posts: 3
Quote urielgolab Replybullet Posted: 16 Nov 2012 at 7:35am
I've tried what you suggested and results were very improved. However, i still have to reduce it more, and will try to make some formatting from SQL to reduce Crystal overhead.

Thank you very much again.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.047 seconds.