Click here to Skip to main content
15,911,035 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
I am a newbie at this, and I have searched all the forums and haven't found the answer I am looking for. I have four reports and only two of which work, and the other two show "Load Report Failed." I have checked the code and they are all the same, the only difference is the number of parameters. I am not sure if this makes a different but one of my reports' size is 4064KB and this one of the two that came up with the error, it has 4 sub-reports within it. I have checked my file paths and given them full permissions, and made sure my password and ID are correct. I am using Crystal Report on VS2010 to export to PDF with a "quick click export button". All the reports work fine on my developing computer, but when I install it on another computer it gives me this issue. I had installed .net Famework 4 and Crystal Report Redistributable for 4.0 Framework, not sure if I need anything else. Here is my code for that one with 4 sub-reports, thank you in advance.
VB
Try

           Dim SavingString As String = ""
           'SavingString = "C:\Windows\Temp\" & CStr(Me.MillNameLabel1.Text) & "Quote" & CStr(Me.QuoteNumberLabel1.Text) & ".pdf"
           SavingString = "C:\Reports\" & CStr(Me.MillNameLabel1.Text) & "Quote" & CStr(Me.QuoteNumberLabel1.Text) & ".pdf"
           Dim cryRpt As New ReportDocument
           cryRpt.Load("C:\Program Files\ECSBOM\ECSBOM\ReportTemplates\QuoteReport.rpt")
           cryRpt.SetDatabaseLogon("CrystalReportUser", "123456")

           Dim crParameterDiscreteValue As ParameterDiscreteValue
           Dim crParameterFieldDefinitions As ParameterFieldDefinitions
           Dim crParameterFieldLocation As ParameterFieldDefinition
           Dim crParameterValues As ParameterValues

           crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields

           crParameterFieldLocation = crParameterFieldDefinitions.Item("QuoteNumber")
           crParameterValues = crParameterFieldLocation.CurrentValues
           crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
           crParameterDiscreteValue.Value = CInt(Me.QuoteNumberLabel1.Text)
           crParameterValues.Add(crParameterDiscreteValue)
           crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

           ReportViewForm.CrystalReportViewer1.ReportSource = cryRpt
           ReportViewForm.CrystalReportViewer1.Refresh()

           Dim CrExportOptions As ExportOptions

           Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()

           Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
           CrDiskFileDestinationOptions.DiskFileName = SavingString
           CrExportOptions = cryRpt.ExportOptions
           With CrExportOptions
               .ExportDestinationType = ExportDestinationType.DiskFile
               .ExportFormatType = ExportFormatType.PortableDocFormat
               .ExportDestinationOptions = CrDiskFileDestinationOptions
               .ExportFormatOptions = CrFormatTypeOptions

           End With
           cryRpt.Export()
           Process.Start(SavingString)
           MainForm.WindowState = FormWindowState.Minimized
       Catch ex As Exception
           MsgBox(ex.ToString)
       End Try
Posted
Updated 30-May-12 4:39am
v2

Since, the code is working for 2 reports and not for other 2 + locally, it works, you need to troubleshoot possible environment based reasons.

Load Report Failed - CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Invalid Report file path
Here troubleshoot with options given in the link: Invalid report file path[^]
 
Share this answer
 
If I were you I'd double check the version of Crystal Reports on your developer machine versus the version on the users' machine where the code fails. My unchanged code with SAP v13 Crystal Reports threw me CrystalDecisions.CrystalReports.Engine.LoadSaveReportException exception with the message "Invalid report file path". I also got CrystalDecisions.CrystalReports.Engine.InvalidArgumentException exception with the message containing "Invalid printer specified".

So dig down into the inner exception what the CrytalReports really threw, check out report file paths, printer settings and other properties you set. The new version seems to be more picky about the correctness of parameters.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900