I want to generate crystal report in pdf format. I had done the same thing by passing one parameter. But this time I want to pass 10 parameter. I followed the same thing what I did for passing one parameter.
But now I got the Error Message "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." Anyone please give suggestions. Thanks in advance. Please modify my Code according to generate Crystal Report in PDF format.
In the Button Click Event I have written the following code.
try
{
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt =
new CrystalDecisions.CrystalReports.Engine.ReportDocument();
string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
string[] str = conn.Split(';');
string server = str[0].Substring(str[0].IndexOf(" = ") + 3);
string database = str[1].Substring(str[1].IndexOf(" = ") + 3);
string userid = str[2].Substring(str[2].IndexOf(" = ") + 3);
string password = "Welc0me";
rpt.Load(Server.MapPath("~/Reports/Marketing/JobOrdersList.rpt"));
for (int i = 0; i < rpt.DataSourceConnections.Count; i++)
rpt.DataSourceConnections[i].SetConnection(server, database, userid, password);
rpt.SetParameterValue(0, DateTime.ParseExact(dcfromdate.DateString.ToString(), DateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None));
rpt.SetParameterValue(1, DateTime.ParseExact(dcTodate.DateString.ToString(), DateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None));
rpt.SetParameterValue(2, ddlCompany.SelectedValue);
rpt.SetParameterValue(3, ddlUnit.SelectedValue);
rpt.SetParameterValue(4, ddlCustomer.SelectedValue);
rpt.SetParameterValue(5, ddlProduct.SelectedValue);
rpt.SetParameterValue(6, ddlScope.SelectedValue);
rpt.SetParameterValue(7, ddlStatus.SelectedValue);
rpt.SetParameterValue(8, ddlGroupBy.SelectedValue);
rpt.SetParameterValue(9, (ChkPrint.Checked == true ? "True" : "False"));
rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, HttpContext.Current.Response, true, "JobOrderList Report");
}
catch (Exception ex)
{
return ex.Message.ToString();
}