本文介绍了将命令文本发送到crystalreport的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨我使用此代码执行查询,并且可以在datagridview中正确显示结果(3条记录).但是当我要将其发送到crystalreportviewer时,它将显示30个rocords!我在2010年使用向导创建了crystalreport.这里的代码:
cmd.commandtext = " 从人员列表中选择fname,lname,startDate,EndDate,请保留其中personid = id和id ='" + 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中不起作用.
当查询在一个表上时,一切正常,但对两个有关系的表不起作用.
感谢
解决方案
hii use this code to execute a query and it works to show result in datagridview exactly right(3 records).but when i want to send it to crystalreportviewer it will show 30 rocords!!
i create crystalreport by using the wizard in 2010.
here thid code:
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
解决方案
这篇关于将命令文本发送到crystalreport的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!