如何在Windows窗体应用程序中使水晶报表更快

本文关键字:水晶 报表 应用程序 Windows 窗体 | 更新日期: 2023-09-27 18:11:49

你好,我正在开发windows窗体应用程序

我已经创建了一个水晶报告。我在我的按钮中有代码,像这样点击:

SqlCommand cmdrslt = new SqlCommand("Staffwiserpt", con.connect);
cmdrslt.CommandType = CommandType.StoredProcedure;
cmdrslt.Parameters.Add("@startDate", SqlDbType.NVarChar, 50, ParameterDirection.Input).Value = frmdateval;
cmdrslt.Parameters.Add("@endDate", SqlDbType.NVarChar, 50, ParameterDirection.Input).Value = Todateval;
cmdrslt.Parameters.Add("@deptid", SqlDbType.Int).Value = deptid;
cmdrslt.Parameters.Add("@empid", SqlDbType.Int).Value = empid;
da.SelectCommand = cmdrslt;
da.Fill(ds);
Staffwisecrpt rpt = new Staffwisecrpt();
if ((ds.Tables(0).Rows.Count > 0)) {
    rpt.SetDataSource(ds.Tables(0));
    rpt.SetParameterValue("frmd", setparmstartd);
    rpt.SetParameterValue("tod", setparmendd);
    rpt.SetParameterValue("Dept", cmbdepartment.Text);
    rpt.SetParameterValue("Employename", cmbemployee.Text);
    CrystalReportViewer1.ReportSource = rpt;
} 
else {
    MessageBox.show("No Records found", MsgBoxStyle.Information);
    return;
}

但是这需要一些时间来显示晶体报告..有没有其他方法来编写这段代码来提高我的晶体报告性能…?
后台工作器怎么样??我能在这段代码中实现它吗?任何帮助都是非常感激的。

如何在Windows窗体应用程序中使水晶报表更快

是的,你可以使用后台worker,看看这个链接。

,但最好的事情是,你必须优化你的代码或查询之前,显示到水晶报告。

LINK2