水晶报表加载缓慢
内容:
根据条件查询数据,在DataGridView里面显示对应信息,然后点击每行信息,在下面CrystalReportViewer显示对应报表
现在已经实现报表的对应加载!
数据源是dateset数据集,数据来源是SQL Server中同一数据库下多个表
但问题就在于,第一次加载相当缓慢,将近花费17、18秒左右
现在想请问一下,是我SQL 语句的问题?!还是存在其他问题。
若有问题怎么修改﹏﹏
以及怎么实现预加载?!
我比较小白﹏﹏希望能解说详细点﹏﹏%>_<%
code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace yyynwl
{
public partial class f_tlddy : Form
{
public f_tlddy()
{
InitializeComponent();
}
private void BTNcx_Click(object sender, EventArgs e)
{
string tmpsql = "select e.id ,e.yfid ,b.mc ,e.ksid ,e.zzrdm ,e.zzrxm ,e.zzsj ,e.dyrdm ,e.dyrxm ,e.dysj ,e.dycs ,e.zhdysj from ejyf_tld e with(nolock),bmml b with(nolock) where e.yfid=b.id";//对应DataGridView中字段
//查询
if (CBksmc.Text != "")
{
tmpsql += " and e.ksid=" + CBksmc.Text.Trim();
}
if (Lyfmc.Text != "")
{
tmpsql += " and b.mc='" + Lyfmc.Text.ToString().Trim() +"'";
}
if (wdy.Checked == true)
{
tmpsql += " and e.dycs is null or e.dycs = 0";
}
else
{
tmpsql += " and e.dycs>0";
tmpsql += " and e.dysj between '"+dtp1.Text.ToString().Trim ()+"' and '"+dtp2.Text.ToString().Trim ()+"'";
if (tdyr.Text != "")
{
tmpsql += " and e.dyrxm+e.dyrdm like '%" + tdyr.Text.ToString().ToUpper().Trim() + "%'";
}
if (tlsh.Text != "")
{
tmpsql += " and e.id like '%" + tlsh.Text.ToString().ToUpper().Trim() + "%'";
}
}
DGVtld.DataSource = c_svisit.getds(tmpsql).Tables[0];
}
private void f_tlddy_Shown(object sender, EventArgs e)
{
try
{
string tmpsql = "select null as ksid,null as mc union select distinct ksid,b.mc from ejyf_tld e with(nolock),bmml b with(nolock) where e.yfid = b.id";
CBksmc.DataSource = c_svisit.getds(tmpsql).Tables[0];
CBksmc.DisplayMember = "ksid";
CBksmc.ValueMember = "ksid";
Lyfmc.DataSource = c_svisit.getds(tmpsql).Tables[0];
Lyfmc.DisplayMember = "mc";
Lyfmc.ValueMember = "mc";
}
catch { MessageBox.Show("数据库连接错误"); }
}
//单选条件
private void ydy_CheckedChanged(object sender, EventArgs e)
{
if (ydy.Checked == true)
{
this.panel6.Enabled = true;
}
}
private void wdy_CheckedChanged(object sender, EventArgs e)
{
if (wdy.Checked == true)
{
this.panel6.Enabled = false;
}
}
//加载报表
private void DGVtld_SelectionChanged(object sender, EventArgs e)
{
int id = Convert.ToInt16(this.DGVtld[0, this.DGVtld.CurrentCell.RowIndex].Value);
ds ds1 = new ds();
c_svisit.getsda("select e.* , b.mc,p.yjph ,p.yjxq from ejyf_tld_pz e,bmml b,ejyf_tld_pzphmx p where e.yfid = b.id and p.tldid = e.tldid and p.spid =e.spid and e.tldid =" + id + " ").Fill(ds1, "ejyf_tld_pz");
ReportDocument rd = new ReportDocument();
rd.Load("ejyf_tld_pz.rpt");
rd.SetDataSource(ds1);
crystalRV.ReportSource = rd;
}
}
}
[解决办法]
没人回答?