0
votes

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. 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;
}
2
Can you post the actual error text? - digital.aaron
the actual error text is load report failed= = - Chee mun Low

2 Answers

1
votes

ReportDocument RD

you are not closing and disposing this object after 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

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

0
votes

in propertis (Copy to the Output Directory) of your .rpt change to Copy if newer or Copy always.