【问题标题】:multiple tables with diff dataset in the same report同一报表中具有不同数据集的多个表
【发布时间】:2015-01-23 21:27:20
【问题描述】:

我想在同一个报告中添加两个表,每个表绑定来自数据库中不同表的数据

我试图让一个数据集包含两个数据库表,并将列分配给报告中的不同表,如下所示:

rptViewer.LocalReport.DataSources.Clear();
            rptViewer.LocalReport.DataSources.Add(new ReportDataSource("reportDS", getData()));  //reportDS the dataset cretated with report

            rptViewer.LocalReport.ReportPath = @"../../portifolioReport.rdlc";  

            rptViewer.RefreshReport();  

private DataTable getData()
    {
        SqlCeCommand cmd = new SqlCeCommand("select * from portifolio where patient_NID='"+NIDTxtBox4.Text+"'", con);
        SqlCeCommand cmd2 = new SqlCeCommand("select * from patients where NID='"+NIDTxtBox4.Text+"'", con);
        DataSet1.DataTable1DataTable dt = new DataSet1.DataTable1DataTable();
          SqlCeDataAdapter dscmd = new SqlCeDataAdapter(cmd);
        SqlCeDataAdapter dscmd2 = new SqlCeDataAdapter(cmd2);
          dscmd.Fill(dt);
          dscmd2.Fill(dt);
        return dt ;

    }

但是在报告中在一个表中添加的每一行都存在问题,在另一个表中添加了空行

我正在使用微软报告,wpf 有人可以帮帮我吗?

【问题讨论】:

    标签: wpf report microsoft-reporting


    【解决方案1】:

    也许你可以加入选择:

    select
        *
    from
        patients a
            inner join
        portifolio b
                on a.patient_NID = b.NID
    

    这会将两张桌子放在一起。您还有其他联接选项,例如:左联接、右联接、交叉联接(每个都取决于您的需要)。我需要有关(如果存在)您要显示的信息之间的关系的更多详细信息。

    【讨论】:

    • 当我使用 join 时存在同样的问题,但存在重复的行而不是空行,报告显示患者数据,因此顶部表格显示基本数据,如姓名、年龄、性别,底部显示每次就诊的患者记录和处方
    猜你喜欢
    • 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
    相关资源
    最近更新 更多