伙计们,我有一个使用报告向导创建的报告。我将患者 ID 从 Form1 传递到承载报告查看器的 Form2。报告显示标题,我将参数传递到查询中。但是它根本不显示任何数据。这是后面的代码。PatientID 当然不为空,因为我设置了一个断点。
public BPReport(string PatientIDVal)
{
InitializeComponent();
string PatientID = PatientIDVal.ToString();
DateTime StartDate = Convert.ToDateTime(DateTime.Today.ToShortDateString()).AddDays(-30);
DateTime EndDate = Convert.ToDateTime(DateTime.Today.ToShortDateString());
txtPatientID.Text = PatientID.ToString();
dtpStartDate.Value = Convert.ToDateTime(StartDate.ToShortDateString());
dtpEndDate.Value = Convert.ToDateTime(EndDate.ToShortDateString());
ReportParameter[] param = new ReportParameter[3];
param[0] = new ReportParameter("StartDate", StartDate.ToString());
param[1] = new ReportParameter("EndDate", EndDate.ToString());
param[2] = new ReportParameter("PatientID", PatientID.ToString());
this.reportViewer1.LocalReport.SetParameters(param);
this.reportViewer1.RefreshReport();
}