如何在Crystal Reports中显示多个表 [英] How Do I Show Multiple Tables In A Crystal Reports

查看:127
本文介绍了如何在Crystal Reports中显示多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计水晶报告。我需要在一个页面上显示两个表。 (换句话说,每页上有两个细节部分。)



这两个表都有彼此独立的记录。例如

表1列是:



|项目编号|商品名称|日期| Qtty已售出售价|

表2列是:



项目编号|项目详情| RemainingQtty |

表1有30行,表2有5行



有人可以帮我解决这个问题吗?



非常感谢,

解决方案

您可以做的是在数据库中使用视图并愚弄水晶报告。请务必使用前缀来帮助您区分两个表格列。视图是在select语句中使用视图时,将数据库中的一个或多个表映射到LOOK,就像一个表一样。不以任何方式修改基础表。你可以说



从myView中选择tbl1Col1,tbl2Col1



而不是说



从tbl1选择tbl1.col1,tbl2.col4



内部联接tabl2

on tbl1。 fkcol = tbl2.pkcol

其中tbl1.myCol> 15和tbl2.yourCol = 21



这个LOOKS就像查询中的一个表格一样不会以任何方式修改基础表。 Crystal永远不会知道差异,只需确保使用视图。



警告:我确信晶体专家不会喜欢这种方法,但它可以在不造成任何损害和最小混乱的情况下工作。如果您在视图名称中使用前缀来暗示其视图(例如vw_MyTable或vwMyTable),它也会有所帮助。水晶专家希望你告诉水晶两个表或者在水晶中做一个内连接sql语句。



在这里读取sql server视图。 [ ^ ]

I'm working on designing a crystal report. I need to display two tables on one page. (In other words, two details sections on each page).

Both the tables have independent records of each other. e.g.
Table 1 columns are:

|Item No | Item Name | Date | Qtty Sold | Selling Price |
Table 2 columns are:

Item No | Item Details | RemainingQtty |
Table 1 has 30 rows and table 2 has 5 rows

Can someone help me out how to achieve this?

Many thanks,

解决方案

What you can do is to use a view in your database and fool crystal reports. Just be sure to use a prefix to help you tell the two table columns apart. A view is a mapping of one or more tables in a database to LOOK like one table when you use the view in a select statement. The underlying tables are not modified in any way. You can say

select tbl1Col1, tbl2Col1 from myView

instead of saying

Select tbl1.col1, tbl2.col4
from tbl1
inner join tabl2
on tbl1.fkcol=tbl2.pkcol
where tbl1.myCol>15 and tbl2.yourCol=21

this LOOKS like one table from the query and the underlying tables are not modified in any way. Crystal will never know the difference, just make sure that the view is used.

Warning: I am sure that crystal experts won't like this approach, but it will work without doing any damage and minimal confusion. It also helps if you use a prefix in the view name to hint that its a view (e.g. vw_MyTable or vwMyTable). The crystal experts would want you to tell crystal about both tables or do an inner join sql statement in crystal.

Read up on sql server views here.[^]


这篇关于如何在Crystal Reports中显示多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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