crystal报告加载失败
本文关键字:失败 加载 报告 crystal | 更新日期: 2023-09-27 18:25:27
我的水晶报告在执行时崩溃了,我可以通过网站查看我的报告,但几分钟后我的报告崩溃了,asp.net告诉我加载报告失败。实际发生了什么问题?y它会在执行期间崩溃吗?
protected void Page_Load(object sender, EventArgs e)
{
//load report
ReportDocument RD = new ReportDocument();
//base on App_Code xsdfile name
top5movie ds = new top5movie();
DataTable dt= new DataTable();
dt.TableName = "Report";
dt = getAllOrders().Tables[0];
ds.Tables[0].Merge(dt);
RD.Load(Server.MapPath("~/CrystalReport2.rpt"));
RD.SetDataSource(ds);
CrystalReportViewer1.ReportSource = RD;
//end load report
}
//report function
public DataSet getAllOrders()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmdSelect = new SqlCommand("selectTop5Movie",conn);
DataSet ds = null;
SqlDataAdapter dts;
try
{
conn.Open();
cmdSelect.Connection = conn;
ds = new DataSet();
dts = new SqlDataAdapter(cmdSelect);
dts.Fill(ds, "movieTitle");
dts.Fill(ds, "userName");
dts.Fill(ds, "uploadDate");
dts.Fill(ds, "movieClicks");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
cmdSelect.Dispose();
if (conn.State != ConnectionState.Closed)
conn.Close();
}
return ds;
}
ReportDocument RD
您没有在using
之后关闭和处置此对象。要么使用
using(ReportDocument RD = new ReportDocument())
{
}
或
RD.Close()
RD.Dispose()
使用后。
可以使用CrystalReport
的实例数量有限制(默认值为75)你可以在regedit
中看到
"HKEY_LOCAL_MACHINE''SOFTWARE''SAP BusinessObjects ''Crystal Reports for.NET Framework 4.0''Report Application Server''Server''PrintJobLimit"
更改为Copy if later或Copy always。