【问题标题】:Load Report Failed...crystal report error加载报告失败...水晶报告错误
【发布时间】:2017-01-22 10:50:25
【问题描述】:
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”。

谢谢。

【问题讨论】:

    标签: c# crystal-reports


    【解决方案1】:

    加载报告错误意味着找不到报告,这意味着路径肯定是错误的,将报告的确切路径放入报告中,即Report.Load("C:\\Program Files\Reports\dailyReport.rpt"); 如果加载它意味着您使用 Application.Startup 给出了错误的路径,重新-验证路径并将您的报告加载代码放在您的按钮单击中,仅用于测试并在此处评论您的问题是否已解决。

    【讨论】:

    • 如果我的回答帮助您追踪您的问题,请选择它作为答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多