Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# C#4.0 , +
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 1:01am
Lubnash832

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
0 OriginalGriff 274
1 Shweta N Mishra 216
2 PIEBALDconsult 210
3 Sergey Alexandrovich Kryukov 185
4 BillWoodruff 174
0 OriginalGriff 7,620
1 Sergey Alexandrovich Kryukov 6,937
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,495


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 7 Apr 2013
Copyright © CodeProject, 1999-2014
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