Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3999182
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:37:26+00:00 2026-05-20T07:37:26+00:00

I want to generate crystal report in pdf format. I had done the same

  • 0

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();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:37:27+00:00Added an answer on May 20, 2026 at 7:37 am
    //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());
                    }
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a Crystal Reports report of one page. Only one. I want to clone
I want to generate a PDF file on server side, and then in response
I want to generate a summary of the files that are in one tree
After reserving a ticket for an travel agency, I want generate a printable report
I am using crystal reports in visual studio 2005 to generate invoices. I want
I want to generate ajax requests on the fly, but I want to make
I want to generate a report to accumulate the total stock quantity that has
I want to generate the random numbers using this loop. When i runs the
can any one send me solution on this problem . Here i want to
This might be a pretty simple question but I'm a Crystal Reports newbie...I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.