rdlc报告表中的两个数据表 [英] Two Datables in a rdlc Report Form

查看:255
本文介绍了rdlc报告表中的两个数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个rdlc文件,需要在单个数据集中显示来自两个不同表的数据。我怎样才能实现这一目标?



我想把一个字段从两个不同的DataTable绑定到一个rdlc文件中的TextBoxes。



谢谢和问候,

I am designing a rdlc file which needs to display data from two different tables in a single dataset. How can i achieve this?

I wanna bind Fields from two different DataTables to TextBoxes in a rdlc file.

Thanks and Regards,

推荐答案

您可以创建一个sql view / store-procedure 并将其设置为report-source

否则

您可以在为报告设置数据源时直接写 sql-query



Happy Coding !

:)
you can create a sql view/store-procedure and set it as report-source
else
you can directly write sql-query while setting data-source for your report.

Happy Coding!
:)


您可以使用自定义列创建DataTable类型对象,然后在查询数据时向这些列添加值:



You can create a DataTable type object with custom columns and then later add values to those columns when you query your data:

DataTable joinedData = new DataTable();
joinedData.Columns.Add("Name",typeof(string));
joinedData.Columns.Add("Address",typeof(string));
joinedData.Columns.Add("Salary",typeof(int));





这里也许姓名和地址在一个表中,也许薪水在另一张表上。



查询数据时,使用左连接或右连接来连接表在您的表中的Id或任何类型的列上,具体取决于您的架构。在创建连接语句并将数据存储在变量(例如var query)之后,然后遍历它并添加每行的数据,例如:





Here maybe Name and Address are in one table and maybe salary is on a different table.

When querying the data, use a left join or right join to join the tables based on Id or any type of column from your tables depending on your schema. After you make a join statement and store the data in a variable such as ''var query'', then iterate through it and add each row''s data like the example:

var query = //Type some form of join LINQ statement to left join the 2 tables and store it in in query variable.

foreach (var item in query)
{
    joinedData.Rows.Add(item.Name,item.Address,item.Salary);
}


这篇关于rdlc报告表中的两个数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆