简体   繁体   English

水晶报表加载失败

[英]crystal report load failed

my crystal report crashed in execute time, i able to view my report though website, but few minutes later my report is crashed and asp.net told me that Load report Failed. 我的水晶报表在执行时间崩溃了,我可以通过网站查看报表,但是几分钟后我的报表崩溃了,asp.net告诉我加载报表失败。 what is problem actually happen?y it will crashed during execute time? 实际发生什么问题?在执行期间会崩溃吗?

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 报表文件RD

you are not closing and disposing this object after using . 您不关闭和处置后,该对象using Either use 无论使用

using(ReportDocument RD = new ReportDocument())
{
}

or 要么

RD.Close()
RD.Dispose()

After using it. 使用后。

There is a limit on number of instances you can use of CrystalReport (default value is 75 ) you can see that in regedit 您可以使用CrystalReport的实例数是有限制的(默认值为75 ),您可以在regedit看到

"HKEY_LOCAL_MACHINE\\SOFTWARE\\SAP BusinessObjects\\Crystal Reports for .NET Framework 4.0\\Report Application Server\\Server\\PrintJobLimit" “ .NET Framework 4.0的HKEY_LOCAL_MACHINE \\ SOFTWARE \\ SAP BusinessObjects \\ Crystal Reports \\ Report Application Server \\ Server \\ PrintJobLimit”

.rpt的属性(复制到输出目录)中,如果较新则更改为“复制”或“始终复制”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM