创建报表查看器报表时在另一个数据表中查找值
我有一个在我的应用程序中创建的本地报告。它显示我的访问数据库中名为“历史记录”的表的内容。其中一列是“ID”,它引用另一个表“Employees”中的主键。
我的报告在刷新时显示员工的 ID,但我当然希望它显示员工的姓名。
简而言之,我需要能够在 rldc 文件中的另一个表上执行查找。我该怎么办呢?
I have a local report that I created in my application. It displays the contents of a table in my access database called "History". One of the columns is "ID" and it refers to the primary key in another table "Employees".
My report shows the employee's ID when it is refreshed but of course I want it to display the employee's name instead.
In short, I need to be able to perform a lookup on another table in my rldc file. How can I go about that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您通过数据适配器和类型化数据集从数据库获取数据。像这样的东西?
然后,您转到数据集并将表适配器中的查询修改为类似这样的
select h.*,e.EmployeeName from History h
内部联接Employees e on e.ID = h.UserID
然后数据集将被修改以包含历史表中所有行的EmployeeName 列。然后“员工姓名”列就可以直接在您的报告中找到
I assume you fetch data from the database through a dataadapter and a typed dataset. something like this?
Then you go to the dataset and modify the query in your tableadapter to something like this
select h.*,e.EmployeeName from history h
inner join Employees e on e.ID = h.UserID
Then the datset will be modified to include the column EmployeeName on all rows in the History table. Then the column "employeename" is directly available in yyour report
下面是如何使用 SQL 连接员工表和历史表的示例。我的 Access 很生锈,因此语法可能不完美,但这应该演示了这个概念。显然,我编写了列名称,因此您必须将列更改为您需要的任何名称。
Here is an example of how to join your employee and history tables with SQL. My Access is rusty, so the syntax might not be perfect, but this should demonstrate the concept. Obviously, I made up the column names, so you will have to change the columns to whatever you need.