P
parekhpujab
Hi all,
I have a crystal report with more than 1 page and binding it to Crystal Report viewer on asp.net web page. I am using CR version 13.0.2 and .net 4.5 with vs2012.
After publishing on web server, my report works fine for few hours and then it crashes giving me the error message "the maximum report processing jobs limit configured by your system administrator has been reached"
I went thro' many posts and blogs which says i need to use reportDocument.Close() and reportDocument.Dispose() methods on page unload. But then if i use that, am not able to navigate thro' my CR pages.
Below is my code. Can u please help?
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;
using System.Data;
public partial class Test : System.Web.UI.Page
{
DBSql db = new DBSql();
ReportDocument myReportDocument;
protected void Page_Init(object sender, EventArgs e)
{
if (Session[SessionKeys.MyReportDocumentCommission] != null)
{
myReportDocument = (ReportDocument)Session["MyReportDocumentCommission"];
CrystalReportViewer1.ReportSource = myReportDocument;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindCrystalReport();
}
}
private void BindCrystalReport()
{
string sql = "select * from customer";
DataSet ds = db.GetDataSet(sql);
if (ds != null)
{
myReportDocument = new ReportDocument();
myReportDocument.Load(Server.MapPath("Commission.rpt"));
myReportDocument.DataSourceConnections.Clear();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
crConnectionInfo.ServerName = "myserver";
crConnectionInfo.DatabaseName = "myDataBase";
crConnectionInfo.UserID = "user";
crConnectionInfo.Password = "mypwd";
CrTables = myReportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
myReportDocument.SetDataSource(ds.Tables[0]);
myReportDocument.Refresh();
Session["MyReportDocumentCommission"] = myReportDocument;
//--Binding report with CrystalReportViewer
CrystalReportViewer1.ReportSource = myReportDocument;
CrystalReportViewer1.DataBind();
ParameterFields myParams = new ParameterFields();
ParameterField myParam1 = new ParameterField();
ParameterDiscreteValue myDiscreteValue1 = new ParameterDiscreteValue();
// Set the ParameterFieldName to the name of the parameter
// created in the Field Explorer
myParam1.ParameterFieldName = "TradingName";
myDiscreteValue1.Value = "MyTradingName";
myParam1.CurrentValues.Add(myDiscreteValue1);
// Add param object to params collection
myParams.Add(myParam1);
// Assign the params collection to the report viewer
CrystalReportViewer1.ParameterFieldInfo = myParams;
CrystalReportViewer1.EnableParameterPrompt = false;
}
}
}
I have a crystal report with more than 1 page and binding it to Crystal Report viewer on asp.net web page. I am using CR version 13.0.2 and .net 4.5 with vs2012.
After publishing on web server, my report works fine for few hours and then it crashes giving me the error message "the maximum report processing jobs limit configured by your system administrator has been reached"
I went thro' many posts and blogs which says i need to use reportDocument.Close() and reportDocument.Dispose() methods on page unload. But then if i use that, am not able to navigate thro' my CR pages.
Below is my code. Can u please help?
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;
using System.Data;
public partial class Test : System.Web.UI.Page
{
DBSql db = new DBSql();
ReportDocument myReportDocument;
protected void Page_Init(object sender, EventArgs e)
{
if (Session[SessionKeys.MyReportDocumentCommission] != null)
{
myReportDocument = (ReportDocument)Session["MyReportDocumentCommission"];
CrystalReportViewer1.ReportSource = myReportDocument;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindCrystalReport();
}
}
private void BindCrystalReport()
{
string sql = "select * from customer";
DataSet ds = db.GetDataSet(sql);
if (ds != null)
{
myReportDocument = new ReportDocument();
myReportDocument.Load(Server.MapPath("Commission.rpt"));
myReportDocument.DataSourceConnections.Clear();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
crConnectionInfo.ServerName = "myserver";
crConnectionInfo.DatabaseName = "myDataBase";
crConnectionInfo.UserID = "user";
crConnectionInfo.Password = "mypwd";
CrTables = myReportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
myReportDocument.SetDataSource(ds.Tables[0]);
myReportDocument.Refresh();
Session["MyReportDocumentCommission"] = myReportDocument;
//--Binding report with CrystalReportViewer
CrystalReportViewer1.ReportSource = myReportDocument;
CrystalReportViewer1.DataBind();
ParameterFields myParams = new ParameterFields();
ParameterField myParam1 = new ParameterField();
ParameterDiscreteValue myDiscreteValue1 = new ParameterDiscreteValue();
// Set the ParameterFieldName to the name of the parameter
// created in the Field Explorer
myParam1.ParameterFieldName = "TradingName";
myDiscreteValue1.Value = "MyTradingName";
myParam1.CurrentValues.Add(myDiscreteValue1);
// Add param object to params collection
myParams.Add(myParam1);
// Assign the params collection to the report viewer
CrystalReportViewer1.ParameterFieldInfo = myParams;
CrystalReportViewer1.EnableParameterPrompt = false;
}
}
}