cancel
Showing results for 
Search instead for 
Did you mean: 

Error received when exporting report to pdf using vb.net

SuperCoder
Participant
0 Kudos

This is the error I receive as shown below.

 

CR Error.png

 

Here is the code used.  The report runs fine in the CR viewer, but when I try to export it to a PDF file then I receive the above error.

 

 

 ' Run report
 Try
     CrystalReportViewer1.ReportSource = objReport
     CrystalReportViewer1.Zoom(100)
 Catch SqlExceptionErr As SqlException
     MessageBox.Show(SqlExceptionErr.Message)
 End Try  

' Export report to pdf
  Try
      objReport.ExportToDisk(ExportFormatType.PortableDocFormat, "c:temp\100000026")

   Catch ex As Exception
      MsgBox(ex.ToString)
  End Try

 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

DonWilliams
Active Contributor
0 Kudos

This looks wrong:

"c:temp\100000026")

Should be:

c:\temp\1000000026

You are missing the "\"

Plus you need a file name extension:

rpt.ExportToDisk(ExportFormatType.PortableDocFormat, "c:\temp\1000000026.pdf");

You also need permission to export to C:\temp folder

SuperCoder
Participant
0 Kudos
I changed the path per your suggestion (I feel so dumb) but I still receive the same error mssage. I have read/write access to the c:\temp folder.
DonWilliams
Active Contributor
0 Kudos

My Mistake, I forgot C# needs the escape sequence, try this:

objReport.ExportToDisk(ExportFormatType.PortableDocFormat, "c:\\temp\\100000026.pdf");

You need a double "\\"

 

Answers (0)