RDLC子报表现实超级慢

dyongqing 2013-07-06 04:08:47
if (!IsPostBack)
{
this.ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessingEventHandler);
string strConn = SqlHelper.t6;
SqlConnection conn = new SqlConnection(strConn);
SqlCommand selcmd = new SqlCommand();
selcmd.Connection = conn;
selcmd.CommandText = "select ccuscode from customer";
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = selcmd;
DataSet ds = new DataSet();
ds.Clear();
da.Fill(ds, "rewq");
ReportViewer1.LocalReport.ReportPath = ".\\report.rdlc";
ReportViewer1.Visible = true;
ReportDataSource reSource = new ReportDataSource("DataSet2", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.EnableExternalImages = true;
ReportViewer1.LocalReport.EnableHyperlinks = true;
ReportViewer1.LocalReport.DataSources.Add(reSource);
ReportViewer1.LocalReport.Refresh();
}
}




void SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
{
//注意dataset2必须和你子报表所引用的table 一致
string strConn = SqlHelper.t6;
SqlConnection conn = new SqlConnection(strConn);
SqlCommand selcmd = new SqlCommand();
selcmd.Connection = conn;
selcmd.CommandText = "select ccusname from customer";
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = selcmd;
DataSet ds = new DataSet();
ds.Clear();
da.Fill(ds, "rewq");
e.DataSources.Add(new ReportDataSource("DataSet1", ds.Tables[0]));
}

以上是代码,我就测试下,customer是张客户表,一个是现实客户编码,子报表现实相应的客户名称。 数据将近有几千条。内部的参数我都设置好了,如果主表加上where语句,显示一条记录可以正常显示,而且子报表正常显示相对应额客户名称。但是去掉where的话,统计的话无法显示出来,等了20分钟显示数据库超时。请问到底什么问题?
...全文
763 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
coobai 2013-07-25
  • 打赏
  • 举报
回复
加载子报表为啥要去 "select ccusname from customer";? “一共才几千条记录” 也就是说 上面这个sql执行了几千次。
dyongqing 2013-07-06
  • 打赏
  • 举报
回复
就是说我显示一条记录没问题,但是显示去全部记录,感觉不停在计算,好长时间出不来,一共才几千条记录,不可能这么慢的

4,819

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧