I have multiple crystal reports in a asp.net 3.5 application. Multiple times a day, users are getting a Load Report Failed error. The issue can be resolved by re-starting IIS but this is obviously an annoying error. 3 of the 8 reports have a subreport.
I'm wondering if this is the issue. I am copying an example of the VB code that calls the report to see if there are any programming mistakes there.
lstephens
Member
2 Points
16 Posts
Load Report Failed Issues with Crystal Reports in ASP.NET
May 24, 2012 09:37 PM|LINK
Hello,
I have multiple crystal reports in a asp.net 3.5 application. Multiple times a day, users are getting a Load Report Failed error. The issue can be resolved by re-starting IIS but this is obviously an annoying error. 3 of the 8 reports have a subreport. I'm wondering if this is the issue. I am copying an example of the VB code that calls the report to see if there are any programming mistakes there.
Partial Class Reporting_StoresWithSourcing
Inherits System.Web.UI.Page
Private ReportDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
If Not ReportDoc Is Nothing Then
ReportDoc.Close()
ReportDoc.Dispose()
GC.Collect()
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
'Verify User Security
Dim AppSec As New AppSecurity
If Not AppSec.UserHasAccess(Request.ServerVariables("Logon_User"), "STORESWITHSOURCINGRPT") Then
Response.Redirect("~/SecurityError.aspx")
End If
AppSec =Nothing
'Set Page Title
Dim lblTitle As Label
lblTitle =CType(Master.FindControl("lblTitle"), Label)
lblTitle.Text ="Stores With Sourcing Report"
If Not InitializeReport() Then
Exit Sub
End If
ShowReport()
Else
If Session("StoresWithSourcingReport") Is Nothing Then
If ViewState("ReportIsLoaded") = True Then
'IIS Session Variable Timed-Out - Reload Report
If Not InitializeReport() Then
Exit Sub
End If
ShowReport()
End If
Else
ReportDoc = Session.Item("StoresWithSourcingReport")
End If
CRViewer.ReportSource = ReportDoc
End If
End Sub
Private Function InitializeReport() As Boolean
InitializeReport =True
Try
Dim ReportFile As String = ConfigurationManager.AppSettings("ReportPath") & "StoresWithSourcing.rpt"
ReportDoc =New CrystalDecisions.CrystalReports.Engine.ReportDocument
ReportDoc.Load(ReportFile)
CRViewer.BackColor = Drawing.Color.White
Session.Item("StoresWithSourcingReport") = ReportDoc
Catch ex As Exception
lblErrorMessage.Text = ex.Message
lblErrorMessage.Visible =True
Return False
End Try
Dim User As String = ConfigurationManager.AppSettings("ReportUser")
Dim Pwd As String = ConfigurationManager.AppSettings("ReportUserPassword")
Dim DSN As String = ConfigurationManager.AppSettings("CCReportDSN")
Dim Database As String = ConfigurationManager.AppSettings("ReportDatabase")
Try
ReportDoc.SetDatabaseLogon(User, Pwd, DSN, Database)
ReportDoc.DataSourceConnections(0).SetConnection(DSN, Database, User, Pwd)
CRViewer.Visible =True
CRViewer.ReportSource = ReportDoc
Session.Item("StoresWithSourcingReport") = ReportDoc
Catch ex As Exception
lblErrorMessage.Text = ex.Message
lblErrorMessage.Visible =True
Return False
End Try
End Function
Private Sub ShowReport()
ViewState("ReportIsLoaded") = True
End Sub
End Class