将水晶报表与多个查询绑定 [英] bind crystal report with multiple query

查看:131
本文介绍了将水晶报表与多个查询绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个窗口projet,其中我想通过添加命令将水晶报表与多个查询绑定在一起,但是问题是,当我运行该程序时,它每次都询问数据库的密码和用户名,并且要花很多时间执行

我只有一个水晶报表,我想将其绑定到一个以上的查询中,例如想要查看所有年龄大于50岁的高级员工,而在下一个查询中,我希望查看其部门在同一水晶报表中进行营销的所有员工,但是问题是它只显示第一个查询结果,我这样绑定我的水晶报表...

脚步 .添加新项目->添加水晶报表->创建新的连接->选择数据库->都添加表(tb_Dept& tb_Employee),因为我有部门编号.在我的tb_Employee中->选择要显示的字段->选择水晶报表的格式->完成

hello everybody,

i have window projet in which i want to bind crystal report with multiple query i have done by by adding command but the problem is that when i run the program it asking password and usernam of database every time and the take to much time to execute

i have only single crystal report and i want to bind it with more then one query like want to see all senior employee whose age greater then 50, and in next query i want to see all employee whose department is marketing in the same crystal report, but the problem is that it display only the first query result i bind my crystal report like that...

steps . add new item -> add crystal report -> create new connection -> chose database -> add table both (tb_Dept & tb_Employee) because i have id of dept. in my tb_Employee -> chose the field to display -> select format for crystal report -> finish

if(comboBox1.SelectedIndex==0)
           {
               //qry= "query for senior employee"
           }
           else if(comboBox1.SelectedIndex==1)
           {
            //qry= "query for marketing employee"
           }
           /* add namespace
             using CrystalDecisions.Shared;
             using CrystalDecisions.CrystalReports.Engine; */
           SqlDataAdapter adp=new SqlDataAdapter(qry,/*connection*/);
           DataTable dt=new DataTable("dt1");
           adp.Fill(dt);
           ReportDocument rd=new ReportDocument();
           rd.Load(Application.StartupPath+"\\CrystalReport1.rpt");
           crystalReportViewer1.ReportSource=rd;


输出相同,仅显示第一个查询的结果!
请帮助我阅读这个问题的人.

在此先感谢
Parveen Rathi


the output is same only show the result of first query !
plz help me who one read this question.

Thanks in advance
Parveen Rathi

推荐答案

您可以使用子报表.您如何绑定报告?通过推或拉方法?包括您的代码块,这将有助于确定为什么要求您输入用户名和密码.
查看这篇文章,可能会有所帮助:
You can use sub-reports. How are you binding reports? Through push or pull method? Include your code block,this will help in determining why you are being asked for Username and password.
check this article, it might help:link
Also, first try to test your report from the rpt file itself.


请参阅此链接

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-multiple-tables.htm [ ^ ]
see this link

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-multiple-tables.htm[^]


您在这里

创建具有多个表的Crystal报表 [
Here you go

Creating Crystal Report with Multiple Tables[^] (Nice article with good explanation(also with pictures))

OP写道:

我有一个窗口projet,我想通过添加命令将Crystal Report与多个查询绑定在一起,但是问题是当我运行程序每次都要询问数据库的密码和用户名以及要花很多时间执行

i have window projet in which i want to bind crystal report with multiple query i have done by by adding command but the problem is that when i run the program it asking password and username of database every time and the take to much time to execute


为此,您应该在运行时应用登录.

C#Crystal Reports动态登录参数 [了解Crystal Reports中的登录失败错误 [ ^ ]

使用具有.NET的Crystal Reports对数据库登录错误进行故障排除 [ ^ ]


For that you should apply login at runtime.

C# Crystal Reports Dynamic Logon parameters[^]

Free attachment

Understanding the Login Failed Error in Crystal Reports[^]

Troubleshooting Database Login Errors using Crystal Reports with .NET[^]


这篇关于将水晶报表与多个查询绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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