Click here to Skip to main content
11,712,126 members (65,620 online)
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 0:01am
Lubnash912

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 CHill60 335
1 Sergey Alexandrovich Kryukov 254
2 OriginalGriff 230
3 Andy Lanng 160
4 Maciej Los 130
0 CHill60 335
1 Sergey Alexandrovich Kryukov 245
2 OriginalGriff 230
3 Andy Lanng 160
4 Maciej Los 130


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 7 Apr 2013
Copyright © CodeProject, 1999-2015
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