Crystal report load slow on web page

Hi,

I have a web page that exports a crystal report to a PDF then displays that as a web page.

The code is below.  On my local machine the whole process runs in about 5 seconds.   However, the code line doc.Load(fileName);  (shown in the code) is taking about 30 seconds to run on the webserver.  Any ideas why this is?

The rpt file is in the same location as the app, I've installed the latest crystal installer, the report has no printer set and the line of code that attaches the dataset runs straight away, so it is only the part that loads the code.

Any help would be appreciated?

thanks


string identifier = Request.QueryString["identifier"];
            Guid testIdenifier = new Guid(identifier);

            DSTestResultsTableAdapters.tblTestHeaderTableAdapter testHead =
                new BSTResults.DSTestResultsTableAdapters.tblTestHeaderTableAdapter();
            int? testHeaderID = testHead.GetTestHeaderID(testIdenifier);
            if (testHeaderID > 0)
            {

                LogOutput("1");
                //Lets show the results then
                DSTestResultsTableAdapters.ProduceResults results
                    = new BSTResults.DSTestResultsTableAdapters.ProduceResults();
                  results.ProduceTestResults(testHeaderID);
                CrystalDecisions.CrystalReports.Engine.ReportDocument doc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                string fileName = Properties.Settings.Default.ReportPath + Properties.Settings.Default.ReportFileName;
                DSTestResults.tblTestHeaderDataTable resultsData = new DSTestResults.tblTestHeaderDataTable();
                DSTestResultsTableAdapters.ShowTestResultsTableAdapter testRes
       = new BSTResults.DSTestResultsTableAdapters.ShowTestResultsTableAdapter();
                DSTestResults.ShowTestResultsDataTable testResData = testRes.GetData(testHeaderID);
                //load the rpt file to document
                doc.Load(fileName);

                doc.SetDataSource((DataTable)testResData);

                //set the export options to PDF

                ExportOptions exportOpts = doc.ExportOptions;

                exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;

                exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;

                exportOpts.DestinationOptions = new DiskFileDestinationOptions();

                // Set the disk file options.
                DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
                string ExportPath = Properties.Settings.Default.ReportPath + "reportoutput\\" + identifier + ".pdf";
                ((DiskFileDestinationOptions)doc.ExportOptions.DestinationOptions).DiskFileName = ExportPath;
                //export the report to PDF rather than displaying the report in a viewer
                doc.Export();


                //force download dialog to download the PDF file at user end.
                //Set the appropriate ContentType.
                Response.ContentType = "Application/pdf";
                //Get the physical path to the file.
                string FilePath = ExportPath;
                //Write the file directly to the HTTP content output stream.

                Response.WriteFile(FilePath);
                Response.End();
            }
            else
            {
                Response.Write("Invalid Report");
            }

Open in new window

LVL 2
kintonAsked:
Who is Participating?
 
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
This is probably due to the following known issue that is fixed in FixPack 3.5:
----------------------
ADAPT01496545
Description:
Crystal Reports reports that have an SQL Expression take a long time to load if the original database is unreachable.  
This problem occurs because the ReportDocument.Load function tries to connect to the original SQL server even if it is not used in
the report.
New Behavior:
This problem is resolved.
----------------------
0
 
mlmccCommented:
How are you loading on your machine?

How did you determine that that line is the bottleneck?

mlmcc
0
 
kintonAuthor Commented:
I'm using exaclty the same code on my machine, and just running it in debug mode.  That line of code runs instantly on my machine.  Again the report is sitting in the same folder as the app.

I'm determining the bottle neck as I added code to output a time stamp to a text file at every line of code, the time stamp above and below the line of code I mention always has a massive gap between it.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
mlmccCommented:
Is there a lot of activity on the network?

Is this running from your machine?

mlmcc
0
 
kintonAuthor Commented:
No, nothing else is running on the webserver, and there is no network connection at that point.

On my local machine this runs fine.
0
 
mlmccCommented:
When you said there is no printer set did  you mean the NO PRINTER option is set?

mlmcc
0
 
kintonAuthor Commented:
Yes, the NO PRINTER option is set.
0
 
kintonAuthor Commented:
Hi,

I probably omitted some key info.  My dev version of crystal reports is 8.5..

However, I have installed the latest run time that comes packaged with VS2008.  It looks to me like this service pack is for the dev machine NOT the production machine.  Is that correct?
0
 
kintonAuthor Commented:
IdoMillet - ok, your answer has given me the solution in a round about way, I started playing with the DB connection and found that connecting using ADO rather than ODBC was the answer!

I'm just testing, but will assign you the points shorlty assuming all is well.

Thanks for your help
0
 
mlmccCommented:
You need to install the runtimes for CR 8.5 on the server.  Crystal is converting the report to the new report format when you use the CR2008 runtimes.

mlmcc
0
 
kintonAuthor Commented:
Part solution as it led me to the actual solution.  Without this I would not have found out the answer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.