Click here to Skip to main content
13,093,097 members (63,371 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: , +
i want to export crystal report to pdf i want to display i am getting error Invalid report file path. while exporting
i am using this code


 protected void Button2_Click(object sender, EventArgs e)
    {
        string query;
 
        //    string q = Request.QueryString["q"];
        con.Open();
        query = "select * from Tech_data where id ='" + TextBox1.Text + "'";
        cmd = new SqlCommand(query, con);
        da = new SqlDataAdapter(cmd);
        dt.Clear();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
 
           // ReportDocument Report = new ReportDocument();
            cryRpt.Load(Server.MapPath("~/CrystalReport.rpt"));
            cryRpt.SetDataSource(dt);
            //query = "select * from Tech_data where id ='" + TextBox1.Text + "'";
            //cmd = new SqlCommand(query, con);
            //da = new SqlDataAdapter(cmd);
            //dt1.Clear();
            //da.Fill(dt1);
            cryRpt.SetDatabaseLogon("sa", "123456789", @"TRAINING-ROOM-8", "Technical_sup");
            CrystalReportViewer1.ReportSource = cryRpt;
            CrystalReportViewer1.DataBind();
            CrystalReportViewer1.RefreshReport();
        }
        con.Close();
    }
    protected void btnShow_Click(object sender, EventArgs e)
    {
        ExportOptions CrExportOptions;
        DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
        PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
        CrDiskFileDestinationOptions.DiskFileName = pdfFile;
        CrExportOptions = cryRpt.ExportOptions;    <<<--- ERROR
        CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
        CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
        CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
        CrExportOptions.FormatOptions = CrFormatTypeOptions;
        cryRpt.Export();
    }
Posted 7-Apr-13 0:01am
$ultaNn739

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 7 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100