on 09-22-2008 3:35 PM
I have Created a common page that has a CrystalReportViewerControl (name of this page is ShowReport.aspx). The report name and database name that required for the report is being passed in a querystring. The database connection info is being pulled from the web.config file. All of the reports that I am dealing with have dynamic parameters and the Crystal Prompt page is automatically being created by the crystal viewer for these. Everything in my application is working fine except that when I try to access any report for the 76th. time I get the following error "The maximum report processing jobs limit configured by your system administrator has been reached."
I have already researched this error and am aware that the PrintJobLimit can be modifed to increase this limit or can be set to -1 if we need to allow unlimited connections. However doing this is not an option due to the degradation of server performance.
The other option that I have tried is to make sure I close and dispose of the report document object on the Page_unload or the page_SavedStateComplete() however on doing so even the session variable that I am using to store the originally created reportdocument is loosing all of the values it requires to display the report. The session variable is still available i.e. it is still of type report document but it has no values for any of the properties like FileName, database etc , basically for all of those properties it show an error "Invalid File Path" when viewed in debug mode.
I have already tried several approaches but with no luck. Every single time I close the originally created ReportDocument object I loose all the required values in the Session
I am using Crystal Report XI R2 , .Net 2.0 and ASP.net
Following is the code: (Any help will be highly appreciated) Thanks:
Option Strict On
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data.SqlClient
Imports System.IO
Partial Class _ShowReport
Inherits System.Web.UI.Page
Private FechReport As ReportDocument
Dim strSelectedDatabase As String
Dim strReportsFolderPath As String =
System.Configuration.ConfigurationManager.AppSettings("ReportsFolderPath").ToString()
Dim strReportFileName As String
Dim strReportFullPath As String
Dim iInsertedLogId As Integer 'This variable is used to store the inserted log id for the executed report.
Dim strConnString As String = System.Configuration.ConfigurationManager.AppSettings("ConnString").ToString()
Dim strServerName As String = System.Configuration.ConfigurationManager.AppSettings("CR_ServerName").ToString()
Dim strUserName As String = System.Configuration.ConfigurationManager.AppSettings("CR_UserName").ToString()
Dim strPassword As String = System.Configuration.ConfigurationManager.AppSettings("CR_Password").ToString()
Protected Sub Page_OnSaveStateComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SaveStateComplete
If IsPostBack Then
If iInsertedLogId > 0 Then
UpdateReportLog_ReportServedTime(iInsertedLogId)
If Not FechReport Is Nothing Then
FechReport.Close()
End If
End If
End If
End Sub
Sub Page_Unload(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Unload
If Not FechReport Is Nothing Then
'FechReport.Close()
'FechReport.Dispose()
'GC.Collect()
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim sRptFileName As String
If Request.QueryString("database") <> "" Then
strSelectedDatabase = Request.QueryString("database")
Else
Response.Write("A Valid Database has not been supplied to this page")
Response.End()
End If
If Request.QueryString("ReportFileName") <> "" Then
strReportFileName = Request.QueryString("ReportFileName")
strReportFullPath = strReportsFolderPath & strReportFileName
Else
Response.Write("A Valid Report has not been supplied to this page")
Response.End()
End If
sRptFileName = strReportFullPath
If Not IsPostBack Then
FechReport = New ReportDocument
If Not FechReport Is Nothing Then
ShowReport(sRptFileName)
End If
Else
If (Session("oReportDocument") Is Nothing) Then
FechReport = New ReportDocument
ShowReport(sRptFileName)
Else
'FechReport = New ReportDocument
'FechReport = CType(Session("oReportDocument"), ReportDocument)
myCrystalReportViewer.ReportSource = Session("oReportDocument")
'myCrystalReportViewer.ReportSource = FechReport
End If
End If
End Sub
Public Function ShowReport(ByVal strReportFileName As String) As Boolean
Dim blNoErrors As Boolean = True
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
FechReport.FileName = strReportFileName
myCrystalReportViewer.ReportSource = FechReport
crConnectionInfo = New ConnectionInfo()
With crConnectionInfo
.ServerName = strServerName
.DatabaseName = strSelectedDatabase
.UserID = strUserName
.Password = strPassword
End With
Try
crDatabase = FechReport.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
Catch ex As Exception
Response.Write(ex.Message & ControlChars.NewLine & ex.InnerException.ToString & ControlChars.NewLine)
Exit Function
End Try
Session("oReportDocument") = FechReport
'FechReport.Close()
'FechReport.Dispose()
'GC.Collect()
Return blNoErrors
End Function
End Class
please post your question in the Business Onjects SDK Application Development Forums.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.