0

同じレポートに 2 つのテーブルを追加し、それぞれデータベース内の異なるテーブルからのデータをバインドしたい

次のように、1 つのデータセットに 2 つのデータベース テーブルを含め、レポート内の異なるテーブルに列を割り当てようとしました。

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 ;

    }

しかし、レポートで1つのテーブルに追加された各行に問題があり、空の行が他のテーブルに追加されました

私はマイクロソフトのレポートを使用しています.wpfは誰でも私を助けてくれますか?

4

1 に答える 1

0

多分あなたは選択に参加することができます:

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

これにより、2 つのテーブルが結合されます。左結合、右結合、クロス結合など、他の結合オプションがあります (それぞれがニーズに応じて異なります)。あなたが表示しようとしている情報の間の関係(存在する場合)についての詳細が必要です。

于 2015-01-24T11:45:04.303 に答える