exporting crystal report to pdf RRS feed

  • Question

  • User1046245955 posted

    anyone got idea on how to auto export the crystal report to pdf using c# .net

    here's my code:

    using System;
    using System.Data;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;
    using System.Data.Odbc;
    using System.Data.OleDb;
    using CrystalDecisions.Shared;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Web;

    public partial class staff_printcertificate : System.Web.UI.Page


    protected void Page_Load(object sender, EventArgs e)

    if (Page.IsPostBack == false)

    clsStaffEntity objstaffinfosid = new clsStaffEntity();
    clsStaffInfoDAL objstaffDALsid = new clsStaffInfoDAL();

    string sidno = Session["StaffID"].ToString();
    objstaffinfosid.StaffID = sidno;
    DataTable tblstaffinfosid = objstaffDALsid.loadleave(objstaffinfosid);
    _empInfo = GetEmpInfo((string)Session["StaffID"]);

    ReportDocument reportdocument1 = new ReportDocument();

    TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
    TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
    ConnectionInfo crConnectionInfo = new ConnectionInfo();
    crConnectionInfo.ServerName = "dbserver";
    crConnectionInfo.DatabaseName = "dbserver";
    crConnectionInfo.UserID = "username";
    crConnectionInfo.Password = "pswd";
    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
    CrystalReportViewer1.LogOnInfo = crtableLogoninfos;
    CrystalReportViewer1.EnableParameterPrompt = false;

    ParameterDiscreteValue crtParamDiscreteValue;
    ParameterField crtParamField;
    ParameterFields crtParamFields;

    crtParamDiscreteValue = new ParameterDiscreteValue();
    crtParamField = new ParameterField();
    crtParamFields = new ParameterFields();

    crtParamDiscreteValue.Value = Request.QueryString["bg"].ToString();
    crtParamField.ParameterFieldName = "bg";
    CrystalReportViewer1.ParameterFieldInfo = crtParamFields;

    if (empcontype == "1")
    CrystalReportViewer1.ReportSource = reportdocument1;



    Monday, March 17, 2014 7:33 AM

All replies

  • User1208776063 posted

    how to auto export the crystal report to pdf using c# .net

    You can try using ExportToHttpStream method

    using CrystalDecisions.Shared;
    //no need to give attachment name, I believe this will display pdf in the browser
    reportdocument1.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "");

    Monday, March 17, 2014 7:44 AM
  • User1046245955 posted

    ill try to put the exporttohttpstream method but got an error..

    Missing parameter values.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Runtime.InteropServices.COMException: Missing parameter values.

    Monday, March 17, 2014 7:53 AM