Click here to Skip to main content
15,909,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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,
Posted
Updated 16-Jan-15 2:14am
v2
Comments
DamithSL 15-Jan-15 7:44am    

1 solution

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.[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900