简体   繁体   中英

how make crystal report faster in windows form application

Hi i working on windows form application

I have created one crystal report . i have code in my button click like this:

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;
}

but this is taking some time to show the crystal report..is there any other way to write this code for improving my crystal report performance..?
how about background worker ?? i can implement that to this code? any help is very appreciable?

Yes, you can use background worker, take a look at this LINK .

but the best thing is you must optimize your code or query before displaying it to crystal report.

UPDATE

LINK2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM