Adil Mammadov
Adil Mammadov

Reputation: 8686

Crystal reports ExportToDisk consumes a lot of time

I have a console application in C# which works with crystal reports. I am loading report (only once) using:

    static ReportDocument cryReportDocument = new ReportDocument();

    static void Main(string[] args)
    {            
        cryReportDocument.Load("reportLocation");
        ....
        //I am exporting about 20.000 .pdf files
        while(true)
        {
            ....
            //destianationPath is file location 
            ExportToPdf(destinationPath)
        }
    }

Then I am exporting this report to pdf file using:

    //Export pdf file
    static void ExportToPdf(string destianationPath)
    {                     
        cryReportDocument.SetDatabaseLogon("userName", "password", "Database", "");
        //Adding paremeters to report
        cryReportDocument.SetParameterValue(.., ..);    
        //This line consumes a lot of time now  
        cryReportDocument.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, destianationPath);
    }

I used this program before (about two or three days before) to export about 15.000 .pdf files and it worked very well. Exported one .pdf file in approximately less then one second. I changed nothing in my code but that line takes about 5 seconds to export one .pdf file. What can cause to this? Computer is the same, I have changed nothing. But it is not working properly. Can anyone help?

Upvotes: 2

Views: 2569

Answers (1)

user1378730
user1378730

Reputation: 930

Could it be the database that is slow? (as requested by Adil)


Additional info (hope you don't mind):

The ExportToDisk method causes crystal to actually execute the database query. The best test in this case would be to directly execute the query to see how long that takes. Adjust as necessary.

Upvotes: 2

Related Questions