Skip to content

Not able to generate pdf file from crystal report

Madhav

Asked Dec 9, 2015, 9:17 PM EST1 answer
Share
LinkedInX
i have done code for pdf generation and that is absolutly working on local host  but on another machine i am accessing the same application with the help of IIS server ,But the code i have done that is not able to generate PDF file on another machine and also not able to generate file name dyanamically,where as these things absolutly working on local host(machine on which i have developed application)
the code is as bellow  
 
Java
protected void Button2_Click(object sender, EventArgs e)
        {
            int QuotationId = Convert.ToInt32(Session["QuotationId"]);
            lbl_QuotationId.Text = QuotationId.ToString();
            CrystalReportViewer1.Visible = true;
            SqlConnection connection = new SqlConnection(CS);
            SqlConnection connection1 = new SqlConnection(CS);
            connection.Open();
            SqlCommand command = new SqlCommand("Select QuotationId,Comp_CompanyName,Comp_CompanyCity,Comp_CompanyAddress,comp_Pin,comp_ContactNo,cust_CustomerName,Desccription,Price,Quantity,LineTotal,Country,DeliveryPeriod,Excise,Taxes,Freight,PayementTerms,RexrothPartNo From quotation where QuotationId=" + lbl_QuotationId.Text.Trim() + "", connection);
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            FinalQuotation1 dataset = new FinalQuotation1();
            adapter.Fill(dataset);
            ReportDocument Report = new ReportDocument();
            Report.Load(Server.MapPath("FinalQuotationReport.rpt"));
            Report.SetDataSource(dataset.Tables[1]);
            CrystalReportViewer1.ReportSource = Report;
            Report.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true,"IND " + lbl_QuotationId.Text.Trim()+"_FY15_16"+".pdf");
        }
 
need help
Thanks in advance 
 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi Madhav
     I Have Check Your Problem .You cannot Pass CrystalReportViewer1 ReportSource  in Export in Pdf So Check Code 
     
    Java
    protected void Button2_Click(object sender, EventArgs e)
    {
    int QuotationId = Convert.ToInt32(Session["QuotationId"]);
    lbl_QuotationId.Text = QuotationId.ToString();
    CrystalReportViewer1.Visible = true;
    SqlConnection connection = new SqlConnection(CS);
    SqlConnection connection1 = new SqlConnection(CS);
    connection.Open();
    SqlCommand command = new SqlCommand("Select QuotationId,Comp_CompanyName,Comp_CompanyCity,Comp_CompanyAddress,comp_Pin,comp_ContactNo,cust_CustomerName,Desccription,Price,Quantity,LineTotal,Country,DeliveryPeriod,Excise,Taxes,Freight,PayementTerms,RexrothPartNo From quotation where QuotationId=" + lbl_QuotationId.Text.Trim() + "", connection);
    SqlDataAdapter adapter = new SqlDataAdapter(command);
    FinalQuotation1 dataset = new FinalQuotation1();
    adapter.Fill(dataset);
    ReportDocument Report = new ReportDocument();
    
    Report.Load(Server.MapPath("FinalQuotationReport.rpt"));
    Report.SetDataSource(dataset.Tables[1]);
    CrystalReportViewer1.ReportSource = Report;       ////////////////////////////ReportSource/////////////////
    Report.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true,"IND " + lbl_QuotationId.Text.Trim()+"_FY15_16"+".pdf");
    }
    0