如何在水晶报表中显示多个表格数据 [英] How to display multiple table data in crystal report

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

问题描述

该项目包含两个表1)PatientTB&2)ListTB,

PatientTB包含所有患者详细信息,ListTB包含患者购买的项目。

现在列Patient_Id是PatientTB中的主键,同一列是ListTB表的外键。

当我与上表中的任何人创建水晶报表时,它工作正常。

但是当我选择这两个表时,没有数据显示。



如果我从数据集晶体报告中选择PatientTB或ListTB将正常工作。

但是由于两个表中的主外键关系,两个表的选择都不能显示任何内容。



我的查询是:



con.Open();

cmd = new SqlCommand(SELECT Date,Doctor,Patient.Patient_Id,Patient_Name,Contact_No,Payment_Type,Item_Count,Grand_Total,List.Batch_No, List.Item_Code,List.Item_Name,List.Exp_Date,List.Qwantity,List.MRP,List.Amount FROM Patient INNER JOIN List ON Pati ent.Patient_Id = List.Patient_Id WHERE Patient.Patient_Id ='+ Main.txt_crs_pid.Text +',con);

SqlDataReader sdr = cmd.ExecuteReader();

DataTable dt = new DataTable();

dt.Load(sdr);

CrystalSale report = new CrystalSale();

report.SetDataSource(dt);

crystalReportViewer1.ReportSource = report;

con.Close();



提前感谢你。

The project contains two tables 1) PatientTB & 2) ListTB,
PatientTB contains all patient details, and ListTB consist of item that patient's purchase.
now the column Patient_Id is an primary key in PatientTB and same column is an foreign key to ListTB table.
when I create a crystal report with anyone of above table it works fine.
but when I select both the tables no data will display.

if I select PatientTB or ListTB from dataset crystal report will work fine.
but selection of both tables can not display anything because of relationship of primary-foreign key in both the tables.

my query is :

con.Open();
cmd = new SqlCommand("SELECT Date,Doctor,Patient.Patient_Id,Patient_Name,Contact_No,Payment_Type,Item_Count,Grand_Total,List.Batch_No,List.Item_Code,List.Item_Name,List.Exp_Date,List.Qwantity,List.MRP,List.Amount FROM Patient INNER JOIN List ON Patient.Patient_Id = List.Patient_Id WHERE Patient.Patient_Id = '" + Main.txt_crs_pid.Text + "'", con);
SqlDataReader sdr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(sdr);
CrystalSale report = new CrystalSale();
report.SetDataSource(dt);
crystalReportViewer1.ReportSource = report;
con.Close();

Thanking you in advance.

推荐答案

查看本教程

C#来自多个表的Crystal Reports [ ^ ]


尊敬的先生,
$ b vb.net中的$ b

我想从o打印报告ne table

喜欢这个

我的原始表



SR年金额

1 2009 1000

2 2008 2000

3 2009 4500

4. 2008 1000



我想打印它像



SR 2008 2009

1 3000 5500


年数固定



请帮助



Mangesh Rajput
Dear sir,
in vb.net
I want to print report from one table
like this
My origional table

SR Year Amount
1 2009 1000
2 2008 2000
3 2009 4500
4. 2008 1000

I want to print it like

SR 2008 2009
1 3000 5500

Number of Years are fixed

Please help

Mangesh Rajput


如果你使用多表意味着你应该使用单独的表数据源来查看水晶报告



在你的代码中



report.SetDataSource(dt);



更改为



If u r using Multiple Table means u should use separate table datasource to view the crystal report

In your code

report.SetDataSource(dt);

change to

report1.Database.Tables[0].SetDataSource(dd.Tables[0]);
report1.Database.Tables[1].SetDataSource(dd1.Tables[0]);





如果你使用2意味着你应该为水晶报告调用2个数据源



if u are using 2 means u should call 2 datasource for crystal report


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

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