0

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

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

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 有人可以帮助我吗?

4

1 回答 1

0

也许你可以加入选择:

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

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

于 2015-01-24T11:45:04.303 回答