水晶报表查询显示数据问题
我用水晶报文推模式访问数据。 请问为什么显示的数据不是查询出来的,而是最初绑定数据源的数据呢?
查询的代码:
CrystalDecisions.CrystalReports.Engine.ReportDocument rpdoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
OleDBFunc.mcurPath = Application.StartupPath;
rpdoc.Load(Application.StartupPath + @"\Reports\rptPersoninfo.rpt");
DataTable dt = OleDBFunc.GetDtBySql("select * from [personinfo2]");
rpdoc.Refresh();
rpdoc.SetDataSource(dt);
crystalReportViewer1.ReportSource = null;
crystalReportViewer1.ReportSource = rpdoc;
crystalReportViewer1.RefreshReport();
------解决方案--------------------代码改下试试:
rptPersoninfo myReport = new rptPersoninfo();
DataTable dt = OleDBFunc.GetDtBySql("select * from [personinfo2]");
myReport.SetDataSource(dt);
crystalReportViewer1.ReportSource = myReport;