[英]Load Report Failed…crystal report error
public void Reports(string query, CrystalReportViewer crystalReportViewer1, string tblname, string rptname)
{
con.Close();
try {
ReportDocument Report = new ReportDocument();
con.Open();
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
//ds.Tables.Add("Customer_Transaction_Master");
da.Fill(ds, tblname);
// Report.Load(System.Windows.Forms.Application.StartupPath + "\\Reports" + rptname);
Report.Load(Application.StartupPath + "\\Reports" + rptname);
Report.SetDataSource(ds.Tables[tblname]);
Report.Refresh();
crystalReportViewer1.ReportSource = Report;
crystalReportViewer1.RefreshReport();
Report.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
Report.PrintOptions.PaperSize = PaperSize.PaperA4;
Report.PrintToPrinter(1, false, 0, 15);
Report.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
//throw ex;
}
finally
{
con.Close();
}
}
*********** ---------按鈕單擊-------- ******
try
{
frmdailyreport frdp = new frmdailyreport();
gd.Reports("select * from tbl_bill where date='" + dailydate.Text + "' ", frdp.dailycrystal, "tbl_bill", "//daily.rpt");
frdp.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Source);
MessageBox.Show(ex.Message);
}
但仍然無法加載報告...問題是,當我單擊按鈕時,它顯示“加載報告失敗錯誤”,然后單擊“確定”,它顯示水晶報告查看器未顯示報告。
globe.cs是我的類文件,該類文件的對象是“ gd”。
謝謝。
加載報告錯誤表示未找到報告,這意味着路徑絕對錯誤,將報告的確切路徑放入報告中,即Report.Load("C:\\\\Program Files\\Reports\\dailyReport.rpt");
如果加載,則意味着您使用Application.Startup給出了錯誤的路徑,請重新驗證該路徑,然后將報告加載代碼放入按鈕中,單擊按鈕進行測試,然后在此處評論您的問題是否已解決。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.