0
votes

I am trying to export a report but everytime it runs the code to export the crystal report in the crystalreportviewer I get an error message saying "Missing Parameter Values". I've looked through many sources but havent found a solution. I do know that all parameters are filled in because without the export code, the site runs perfectly fine.

Export code

Try
            Dim CrExportOptions As CrystalDecisions.Shared.ExportOptions
            Dim CrDiskFileDestinationOptions As New  _
            CrystalDecisions.Shared.DiskFileDestinationOptions()
            Dim CrFormatTypeOptions As New CrystalDecisions.Shared.PdfRtfWordFormatOptions()
            CrDiskFileDestinationOptions.DiskFileName = _
                                        "c:\crystalExport.pdf"
            CrExportOptions = oRpt.ExportOptions
            With CrExportOptions
                .ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
                .ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
                .DestinationOptions = CrDiskFileDestinationOptions
                .FormatOptions = CrFormatTypeOptions
            End With
            oRpt.Export()
        Catch ex As Exception
            Response.Write(ex.ToString)
        End Try

Also:

  'Try
        '    oRpt.ExportToHttpResponse([Shared].ExportFormatType.PortableDocFormat, Response, True, "ExportedReport")
        'Catch ex As Exception
        '    Response.Write(ex.ToString)
        'End Try

Any help would be great.

4

4 Answers

3
votes

This is caused under 2 reasons. Either, you're not passing(from the program) a required parameter which you have created in the report. Or, you're passing a parameter to the report but you haven't created it in the report.

2
votes

To solve my own problem I found that the code actually exports the instance of the crystal report, whereas I was putting the parameters into the crystalreportviewer after providing the source. Instead I provided the parameters directly into the instance which gets pushed into the crystalreportviewer as a datasource.

:)

0
votes

In my case, there was a subreport that was not correctly linked with the main report.

Check if all the parameters of the subreport is linked with the main report.

Cheers;

0
votes
  1. Have to set required parameters

  2. Set rpt.SetDataSource(dt) even DataTable records count is 0:

         DataTable dt = new DataTable();
         dt.Load(data);
         if (dt?.Rows != null)
         {
           rpt.SetDataSource(dt);
           return true;
         }