Symptom
When export option selected from the Crystal Report Viewer of a .NET Web Application, following error message prompts:
Error: Failed to export using the options you specified. Please check your
options and try again.
Environment
- Crystal Reports Server 2011.
- Crystal Reports for Visual Studio 2010.
- Visual Studio 2010.
Cause
- Due to the stateless nature of web applications the ReportSource of the CrystalReportViewer should be maintained in HttpSession.
- Load() does not actually load the report file that is reference in the method call. It creates a temp copy and uses it to load the report into memory. If we don’t store the report somewhere the data is gone on the postback which results in the error.
Resolution
Store the report source object in HttpSession as given below:
If Session("ReportSource") = Nothing Then
'use RAS to open the report
rptClientDoc = rptAppFactory.OpenDocument(IRptId, 0)
' Do other report related code - such as database logon, parameters, formula work, etc.
'place the ReportClientDocument in session for use with postbacks
Session.Add("ReportSource", rptClientDoc)
End If
CrystalReportViewer1.Visible = True
CrystalReportViewer1.ReportSource = Session("ReportSource")
Note:
It is always recommended to store report source object in HTTPSession.
Keywords
Crystal Server 2011, VS 2010, Session, Reportsource, CR for VS 2010. , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , Problem
Product
SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Server 2011