本文介绍了如何在Crystal Report + C#中的两个表中显示两个不同的查询结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在MSAccess下面有桌子



ID名称分类

1 John ASE

2 Kev ASE

3 Paul ASE

4 Lina SSE

5 Hendry SSE



我需要在一个Crystal Report中的两个表中显示结果

1)一个表用于类别为ASE的名称

2)第二个表名为SSE的名字



我无法在一个表格中显示两个类别的详细信息



请建议我如何做到这一点。我使用C#作为语言生成这个水晶报告



这是脚本,我正在使用

Hi All,

I have below table in MSAccess

ID Name Category
1 John ASE
2 Kev ASE
3 Paul ASE
4 Lina SSE
5 Hendry SSE

I need to display result in two tables in one Crystal Report
1) one table for names with Category "ASE"
2) Second table for names with Category "SSE"

I can't display both categories details in one table

Please suggest how I can do this. I am using C# as language to generate this crystal report

Here is the script , I am using

//CrystalReport1 is main where I want to show subreport
//CrystalReport4 is subreport

CrystalReport1 ObjRpt;

CrystalReport4 ObjRpt1;
 
ObjRpt = new CrystalReport1();

ObjRpt1 = new CrystalReport4();

String StrQuery;

StrQuery="SELECT Id,Name,MemberRank FROM Members WHERE Cat=1";

OleDbDataAdapter adp = new OleDbDataAdapter(StrQuery.ToString(), ControlRules.ClsConnect.Conn);

                DataSet ds = new DataSet();

                int ctr = adp.Fill(ds);

                DataSet1 Ds = new DataSet1();

                adp.Fill(Ds, "Customer");

StrQuery="SELECT Id,Name,SubRank,Ratiopergrop,NHPL,((KLP_Num * 120) - 25) as "RHN_Number" FROM Members WHERE Cat=2";

               OleDbDataAdapter adp1 = new OleDbDataAdapter(result1.ToString(), ControlRules.ClsConnect.Conn);

                DataSet ds1 = new DataSet();

                int ctr1 = adp1.Fill(ds1);

                ds1.Tables[0].Rows.Add(0, "", 0, 0, 0, 0);

                DataSet6 Ds1 = new DataSet6();

                adp1.Fill(Ds1, "Customer1");

                ObjRpt1.SetDataSource(Ds1);

                ObjRpt.SetDataSource(Ds);

                ReportDocument crystalReport = new ReportDocument();

                ReportDocument crystalReport1 = new ReportDocument();

                crystalReport=ObjRpt;

                crystalReport1 = ObjRpt1;

crystalReportViewer1.ReportSource = ObjRpt;

推荐答案


ReportDocument subReport1 = new ReportDocument();
SubreportObject subReportObject1;
subReportObject1= mainReoprtObject.ReportDefinition.ReportObjects["Subreport1"] as SubreportObject;
//"Subreport1" is the subreport object name in main report
subReport1 = subReportObject1.OpenSubreport("mySubreport1.rpt");
subReport1.SetDataSource(datatable1);

ReportDocument subReport2 = new ReportDocument();
SubreportObject subReportObject2;
subReportObject2= mainReoprtObject.ReportDefinition.ReportObjects["Subreport2"] as SubreportObject;
subReport2 = subReportObject2.OpenSubreport("mySubreport2.rpt");
subReport2.SetDataSource(datatable2);


这篇关于如何在Crystal Report + C#中的两个表中显示两个不同的查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 01:28