How to display data in crystal report using 2 sql request and 2 datatables in dataset?

前端 未结 2 1667
误落风尘
误落风尘 2021-01-26 11:23

I have a dataset with 2 datatable aand I need to use 2 sql request to display data in crystal report. So I create 2 datatable in my dataset (DataTable1 and dataTable2) I tried t

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-26 11:41

    You would need to merge the datatables into one and set them. Every time you invoke SetDataSource with a datatable, you are overriding the previous data.

    Use the Merge() functionality to achieve this -

    DataTable dt = ds.Tables["DataTable2"];
    DataTable dt2 = ds.Tables["DataTable1"];
    dt.Merge(dt2);
    report.SetDataSource(dt);
    

提交回复
热议问题