2012-02-22 92 views
0

我的水晶報告在執行時崩潰,我能夠通過網站查看我的報告,但幾分鐘後,我的報告崩潰了,asp.net告訴我,加載報告失敗。實際發生的問題是什麼?它會在執行期間崩潰嗎?水晶報告加載失敗

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; 
} 
+0

您能發佈實際的錯誤文本嗎? – 2012-02-22 22:59:15

+0

實際的錯誤文本是加載報告失敗= = – 2012-02-23 03:51:16

回答

0

您的.rpt的屬性(複製到輸出目錄)更改爲複製如果更新或始終複製。

1

的ReportDocument RD

您不關閉和using處置後該對象。 要麼使用

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

RD.Close() 
RD.Dispose() 

使用後。

有你可以使用CrystalReport實例的數量限制(默認值是) 你可以看到,在regedit

「HKEY_LOCAL_MACHINE \ SOFTWARE \ SAP的BusinessObjects \水晶報表。 NET Framework 4.0 \ Report Application Server \ Server \ PrintJobLimit「

+0

好吧,讓我檢查! – 2017-04-20 11:25:27

+1

@AkhilNair sure .. – 2017-04-20 11:26:43