Serge's Technology View

Talk about Technologies, Software Architecture and Management

Posts Tagged ‘crystalreportviewer’

Expiration of CrystalReport Viewer pages with long running queries

Wow! It worked…

I continue my journey with Crystal Reports Viewer (CRV) inside ASP.Net pages.
Topic of this post is to discuss problems and solutions related to long running queries in CRV.

Before continue I would like to thank Daniel Paulsen from SAP team for his help resolving the issue discussed below.

What are we talking about here?

As it usually happens at some point there is to much data/not optimal query/broken indexes/etc and it is takes significant time to return a result for CR report. As a result ASP.Net page with CRV start to throw errors, acts erratically, and overall strange.

Since we know that it is ASP.net and CRV uses page state and session information then we have usual suspects - session timeout and execution timeout.

Easy? Not so fast… Lets time our query – if it is more then 10 but less then 20 minutes then reason is not an ASP.Net timeout, but CR Engine timeouts.

Crystal Reports Engine Timeouts

Aside from timeouts imposed by .net infrastructure, there are two others which are introduced by Crystal Report itself.

Symptoms:

  • Error similar to ‘Request timed out because there has been no reply from the server in N ms’
  • First Page of the report is displayed but attempt to go to the next page gives JS error related to invalid object ID
  • If report require parameter entry, they are requested again

Cause:

Crystal Reports by default has a timeout of 10 minutes (600,000 ms) before deciding that no data is returned by the query.
Depend on how code behind is implemented for the report page, timeout error may cause different problems and be hidden.

Solution:

Per Daniel’s suggestion I have changed the following settings to a bigger number and it did solve the problem for me

HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Report Application Server\Client SDK\CorbaAdapter\WaitReplyTimeout = 600000

and

HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Report Application Server\InprocServer\EnterpriseRequestTimeout = 600000

Final Note:

There are other settings which are allowed to be set for the CR engine as described in Developer’s Guide for CR 2008 under “Configuring your Web.Config file“. It worth to know about some of them.

How to set default file name for export from CrystalReportViewer in ASP.Net

I have had nice discussion about a new Crystal Reports based web-site today. And everything seems to be fine… Except users want to see a proper default name for the exported files…

Environment:

  • Crystal Reports 2008 engine
  • IIS 7
  • ASP.Net 3.0 page with CrystalReportViewer (CRV) being used to show report passed by parameter

When trying export as PDF (just an example), CRV defaults the name of the file to CrystalReportViewer1.pdf.
Not very nice since associated RPT name is MyVeryOwnReport.rpt and I have many other which I would expect export file at least inherit.

One would expect that Viewer would have a property allowing specify default export name. Not so fast… there is no such thing today exists.

After some head scratching and research, it just happen that Default Export File Name is actually based of the ID property value of the CRV which is still named as CrystalReportViewer1.

Options?

  1. Rename ID value of the control as something else. Still, if we use just one page and load reports dynamically, then it would not help much.
    // ReportPreview.aspx file
    <CR:CrystalReportViewer ID="MyVeryOwnExportFile" />
  2. Another option is to populate Default Export file name in the code
    // ReportPreview.aspx.cs file
    protected void Page_Init(object sender, EventArgs e)
    {
         ...
        // Load report here
        ...
        CrystalReportViewer1.ID = "MyVeryOwnExportFile";
    }

    It is important to have it set before any code would use it to manipulate a page view state and create references.

  3. Trying manually set export options for the Report instance, would not help much unfortunately since viewer would disregard it.
  4. Off course there is always an option of coding export functionality yourself and bypass built-in logic…

This concludes another Crystal Reports dance session.

Valid XHTML 1.0 Transitional  Valid CSS!