c# - How to generate Crystal Report in PDF format while passing Multiple Parameters? -
i want generate crystal report in pdf format. had done same thing passing 1 parameter. time want pass 10 parameter. followed same thing did passing 1 parameter.
but got error message "unable evaluate expression because code optimized or native frame on top of call stack." please give suggestions. in advance. please modify code according generate crystal report in pdf format.
in button click event have written 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")); (int = 0; < 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(); }
//to generate pdf dynamically using system; using system.windows.forms; using crystaldecisions.crystalreports.engine; using crystaldecisions.shared; namespace windowsapplication1 { public partial class form1 : form { reportdocument cryrpt; public form1() { initializecomponent(); } private void button1_click(object sender, eventargs e) { cryrpt = new reportdocument(); cryrpt.load(put crystal report path here\\crystalreport1.rpt"); crystalreportviewer1.reportsource = cryrpt; crystalreportviewer1.refresh(); } private void button2_click(object sender, eventargs e) { try { exportoptions crexportoptions ; diskfiledestinationoptions crdiskfiledestinationoptions = new diskfiledestinationoptions(); pdfrtfwordformatoptions crformattypeoptions = new pdfrtfwordformatoptions(); crdiskfiledestinationoptions.diskfilename = "c:\\csharp.net-informations.pdf"; crexportoptions = cryrpt.exportoptions; { crexportoptions.exportdestinationtype = exportdestinationtype.diskfile; crexportoptions.exportformattype = exportformattype.portabledocformat; crexportoptions.destinationoptions = crdiskfiledestinationoptions; crexportoptions.formatoptions = crformattypeoptions; } cryrpt.export(); } catch (exception ex) { messagebox.show(ex.tostring()); } } } }
Comments
Post a Comment