【发布时间】:2023-03-21 03:52:02
【问题描述】:
我有一个主报告和 5 个子报告,除了 1 个子报告之外,一切都运行良好。
在开发模式下,当我预览主报告时,所有子报告都完美显示数据,尤其是子报告“Symptom/s”很好:
但在生产模式下,子报告“Symptom/s”没有出现:
private void loadReport(Int64 appointmentID)
{
try
{
rd = new ReportDocument();
//For main patient record
SqlCommand cmd1 = new SqlCommand("st_getPatientBill", MainClass.con);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("@appID", appointmentID);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
DataTable dt1 = new DataTable();
da1.Fill(dt1);
rd.Load(Application.StartupPath + "\\Reports\\PrescriptionReport.rpt");
rd.SetDataSource(dt1);
ConnectionInfo ci = new ConnectionInfo();
ci.DatabaseName = "cms";
ci.UserID = "sa";
ci.Password = "12345";
ci.ServerName = "DESKTOP-753VMJS";
Tables tables = rd.Database.Tables;
SqlCommand cmd4 = new SqlCommand("st_getInternalMedicine", MainClass.con);
cmd4.CommandType = CommandType.StoredProcedure;
cmd4.Parameters.AddWithValue("@appID", appointmentID);
SqlDataAdapter da4 = new SqlDataAdapter(cmd4);
DataTable dt4 = new DataTable();
da4.Fill(dt4);
rd.Subreports[0].SetDataSource(dt4);
//For external medicine
SqlCommand cmd3 = new SqlCommand("st_getExternalMedicine", MainClass.con);
cmd3.CommandType = CommandType.StoredProcedure;
cmd3.Parameters.AddWithValue("@appID", appointmentID);
SqlDataAdapter da3 = new SqlDataAdapter(cmd3);
DataTable dt3 = new DataTable();
da3.Fill(dt3);
rd.Subreports[0].SetDataSource(dt3);
//For disease
SqlCommand cmd5 = new SqlCommand("st_getPatientDiseaseWRTAppointment", MainClass.con);
cmd5.CommandType = CommandType.StoredProcedure;
cmd5.Parameters.AddWithValue("@appID", appointmentID);
SqlDataAdapter da5 = new SqlDataAdapter(cmd5);
DataTable dt5 = new DataTable();
da5.Fill(dt5);
rd.Subreports[0].SetDataSource(dt5);
//For symptoms
SqlCommand cmd6 = new SqlCommand("st_getPatientSymptomsWRTAppointment", MainClass.con);
cmd6.CommandType = CommandType.StoredProcedure;
cmd6.Parameters.AddWithValue("@appID", appointmentID);
SqlDataAdapter da6 = new SqlDataAdapter(cmd6);
DataTable dt6 = new DataTable();
da6.Fill(dt6);
rd.Subreports[0].SetDataSource(dt6);
//For tests
SqlCommand cmd7 = new SqlCommand("st_getPatientTestWRTAppointment", MainClass.con);
cmd7.CommandType = CommandType.StoredProcedure;
cmd7.Parameters.AddWithValue("@appID", appointmentID);
SqlDataAdapter da7 = new SqlDataAdapter(cmd7);
DataTable dt7 = new DataTable();
da7.Fill(dt7);
rd.Subreports[0].SetDataSource(dt7);
//For internal medicine
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = ci;
table.ApplyLogOnInfo(tableLogonInfo);
}
crystalReportViewer1.ReportSource = rd;
crystalReportViewer1.RefreshReport();
}
catch (Exception ex)
{
if (rd != null)
{
rd.Close();
}
}
}
详情如上
【问题讨论】:
标签: crystal-reports report subreport