水晶报告在运行时填充 [英] crystal report populated at runtime
本文介绍了水晶报告在运行时填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我第一次使用水晶报告。我想要做的是创建一个单晶报告,在运行时使用select命令填充,因此我编写代码onload事件的页面我的代码是 -
尝试
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@C:\Users\Avi\Documents\Store backup\1Apr\store\Bill.rpt);
con.Open();
adp = new SqlDataAdapter(选择*来自Store_Purchasebill,其中Bill_no =+ bill +,con);
DataSet ds = new DataSet();
adp.Fill(ds,Store_Purchasebill);
if(ds.Tables [0] .Rows.Count> 0)
{
//.......请将报告的整个部分放在下面。 .............
cryRpt.Load(@C:\Users\Avi\Documents\Store backup\1Apr\store\Bill.rpt );
< big> cryRpt.SetDataSource(ds); //这里我收到错误< / big>
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();
}
}
catch(例外se)
{
MessageBox.Show(se.Message.ToString());
}
显示的错误是报告没有表格。我添加了一个空白的Crystal报告,如果我需要添加其他类型的报告,那么请告诉我如何添加它。
提前Thx。
解决方案
这里查看此主题 [ ^ ]用截图清楚地解释了事情
Hi,
This is the first time I'm working with crystal reports. What i am trying to do is crating a single crystal report which populated at runtime using with select command therefore I write the code onload event of page My code is-
try { ReportDocument cryRpt = new ReportDocument(); cryRpt.Load(@"C:\Users\Avi\Documents\Store backup\1Apr\store\Bill.rpt"); con.Open(); adp = new SqlDataAdapter("Select * from Store_Purchasebill where Bill_no=" + bill + "", con); DataSet ds = new DataSet(); adp.Fill(ds, "Store_Purchasebill"); if (ds.Tables[0].Rows.Count > 0) { //.......Put the whole part of report bellow.............. cryRpt.Load(@"C:\Users\Avi\Documents\Store backup\1Apr\store\Bill.rpt"); <big>cryRpt.SetDataSource(ds);// here i get error </big> crystalReportViewer1.ReportSource = cryRpt; crystalReportViewer1.Refresh(); } } catch (Exception se) { MessageBox.Show(se.Message.ToString()); }
The error it show is report has no tables. I added a blank Crystal report if i need to add another type of report then plz tell me how to add that.
Thx in advance.
解决方案
Here check this thread[^] which explains the thing clearly with screenshot.
这篇关于水晶报告在运行时填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文