If you are working with Crystal Report and not handling the Report closing properly you must have faced this error.
"The maximum report processing jobs limit configured by your system administrator has been reached."
The error message is self describing; well now the question is how to resolve this issue. The quick answer is making sure that you end the crystal job successfully, i.e. close the report once the user has closed the report. Yes, you have to do this manually.
I found multiple methods of doing this from groups, putting down the best methods I found in order.
1. Close the report while unloading the report viewer page.
VB.NET code below
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
If Not objRpt Is Nothing Then
objRpt.Close()
objRpt.Dispose()
End If
End Sub
This is the best method as far as I can think.
2. The lazy option – change registry key to accept more or infinite numbers
regedit - > navigate to
HKEY_LOCAL_MACHINE/SOftware/Crystal Decisions/Report Application Server/InprocServer/ReportDocument
Change the value of the field MaxNumOfRecords to -1(For Unlimited No. of records)
Your sys admin may sue you for changing this J
3. I like writing more code, give me an option – ok now for you, the option is create a factory class and when creating class check if the max has reached and clear the old ones. (Not a good idea isn’t it?)
public class ReportFactory
{
protected static Queue rptQueue = new Queue();
protected static ReportClass CreateReport(Type reportClass)
{
object report = Activator.CreateInstance(reportClass);
rptQueue.Enqueue(report);
return (ReportClass)report;
}
public static ReportClass GetReport(Type reportClass)
{
if (rptQueue.Count > MAX_COUNT) ((ReportClass)rptQueue.Dequeue()).Dispose();
return CreateReport(reportClass);
}
}
Choose your own method, as I mentioned my fav is the first one...
Good luck
Rujith
Related posts: