将命令文本发送到crystalreport的问题 [英] problem to send commandtext to crystalreport

查看:63
本文介绍了将命令文本发送到crystalreport的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我使用此代码执行查询,并且可以在datagridview中正确显示结果(3条记录).但是当我要将其发送到crystalreportviewer时,它将显示30个rocords! 我在2010年使用向导创建了crystalreport.

这里的代码:

 cmd.commandtext = "  + txtID.text +  '";
da.selectcommand = cmd;
da.fill(dt);
form1 newform =  form1();
crystalreport1 cr =  crystalreport1();
cr.setdatasource(dt);
newform.crystalreportviewer1.reportsource = cr;
newform.show(); 


问题是:
查询在datagridview中起作用,但在crystalreport Viewer中不起作用.
当查询在一个表上时,一切正常,但对两个有关系的表不起作用.
感谢

解决方案

在以下示例中提供了有用的参考:cmd.commandtext="select fname,lname,startDate,EndDate from personel,leave where personid=id and id='"+txtID.text+"'"; da.selectcommand=cmd; da.fill(dt); form1 newform=new form1(); crystalreport1 cr=new crystalreport1(); cr.setdatasource(dt); newform.crystalreportviewer1.reportsource=cr; newform.show();


problem is:
query works in datagridview,BUT no works in crystalreport viewer.
when query is on one table,everything is ok,BUT no works for 2 tables which have relationships.
thanks

解决方案

Useful reference is available with example at: http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-multiple-tables.htm[^]


这篇关于将命令文本发送到crystalreport的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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