【发布时间】: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