Click here to Skip to main content
15,885,004 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My Crystal Reports take forever to load in my application - at least 2 minutes: This is my code. What do I do wrong?
private void button1p_Click(object sender, RoutedEventArgs e)
        {
            Windows.CrystalReportViewerWindow wnd = new ePAM.Windows.CrystalReportViewerWindow();

            // Change 'OperationalUnitTableAdapter' to appropriate adapter.
            ePAM.Reports.StrategyDataSetTableAdapters.OperationalUnitTableAdapter adapter = new ePAM.Reports.StrategyDataSetTableAdapters.OperationalUnitTableAdapter();
            adapter.Connection.ConnectionString = BusinessLayer.BusinessLayer.GetConnectionString();
            adapter.Fill(dataSet.OperationalUnit);

            // Change 'Operational_Units' to appropriate report.
            Reports.Print.Operational_Units objReport = new Reports.Print.Operational_Units();

            // Change 'dataSet.OperationalUnit' to 'dataSet.***'.
            objReport.SetDataSource(dataSet);

            wnd.MyReportViewer.ReportSource = objReport;
            wnd.MyReportViewer.RefreshReport();
            wnd.ShowDialog();

        }


Thanks in Advance

Suzie
Posted
Updated 15-Apr-16 6:50am
v2

Basically you just create a empty report and open it (no need to set data source or anything you just initiate it)
This will load the crystal reports framework into memory and should cut down loading time drastically.
 
Share this answer
 
Comments
alrajhi20 11-May-14 0:15am    
Would you please send the proper code for initiating it?
Check if the second time you open a crystal report is still loading as slow.

Crystal reports is very very slow on the loading for the first time but should be fast when loading the report (or a different one) for a second time (without closing the application)

If it's the case that it is only for the first time then I suggest that you load a dummy report (in the background on a different thread) when loading your application, without showing the report of course.
 
Share this answer
 
Have you run this under the debugger to see exactly what part of it is slow? Which line is taking the most time?
 
Share this answer
 
basically when you run first time it always slow because opening and loading database is slow. from second time onwards it will become faster. to check create a empty crystal report and run it. you will see it is faster than the database connected crystal report.
 
Share this answer
 
objReport.SetDataSource(dataSet);
 
Share this answer
 
CrystalReportViewer1.Refresh()

in this line it will take more time....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900