Upgrade from Crystal Reports.Net 9 to Crystal Reports XI Developer Edition
Upgraded from Crystal Reports.Net 9 to Crystal Reports XI Developer Edition and the streaming report functionality started generating errors. The Visual Studio.net 2003 did upgrade the Crystal Reports report viewer control but the streaming functionality ceased to work. What backend upgrades are necessary?
Below is the code followed by the error generated.
-----------[ Stream Export Option [1] ]-------
'Dim myExportFile2 As String = Server.MapPath("Reports/output/") & Session.SessionID & ".pdf"
myExportFile = Server.MapPath("Reports/output/") & Session.SessionID & ".pdf"myDiskFileDestintionOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions
myDiskFileDestintionOptions.DiskFileName = myExportFile
'myExportOptions = Report.ExportOptions
Dim s As System.IO.MemoryStream = Report.ExportToStream(ExportFormatType.PortableDocFormat)'' the code below will create pdfs
'' in memory and stream them to the browser
'' instead of creating files on disk.
With HttpContext.Current.Response
'.Clear()
.ClearContent()
.ClearHeaders() '
.ContentType = "application/pdf"
.AddHeader("Content-Disposition", "inline; filename=Report.pdf")
.BinaryWrite(s.ToArray)
.End()
End With
'-----------[/ Stream Export Option [1] ]-----------------------[ Error Generated ]-----------------------
Missing parameter values.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Runtime.InteropServices.COMException: Missing parameter values.
Source Error:
Line 848:
Line 849: 'Dim s As System.IO.MemoryStream = Report.ExportToStream(ExportFormatType.PortableDocFormat)
Line 850: Dim s As System.IO.MemoryStream = Report.ExportToStream(ExportFormatType.PortableDocFormat)
----------------[/ Error Generated ]-----------------------
All Replies
You need to install the crystal runtimes for XI (merge modules), I would also suggest switching your code to:
System.IO.Stream oStream;
byte[] byteArray = null;
oStream = crReportDocument.ExportToStream(ExportFormatType.PortableDocFormat);
byteArray = new byte[oStream.Length];
oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length-1));
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.BinaryWrite(byteArray);
Response.Flush();
Response.Close();Not a whole lot of change, but this is what I've been told is the supported way to do it from Crystal.
Thanks for the feedback
Upgraded code to:
________________________
Dim oStream As System.IO.Stream
Dim byteArray As Byte()
oStream = Report.ExportToStream(ExportFormatType.PortableDocFormat)oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1))
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.BinaryWrite(byteArray)
Response.Flush()
Response.Close()and received the following output:
Missing parameter values.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Missing parameter values.
Source Error:
Line 879: Dim oStream As System.IO.Stream Line 880: Dim byteArray As Byte() Line 881: oStream = Report.ExportToStream(ExportFormatType.PortableDocFormat) Line 882: Line 883: oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1))
Do you have any parameters in your report?
And how did you deploy the Crystal Reports Runtimes?
The issue currently appears to be in the setting of the subreports.
Currenly this is what I am using.
Report.OpenSubreport("Subreport.rpt").SetDataSource(dstable.Tables("Table_1"))
Any ideas on this?
We have the exact same problem, did you ever find a resolution to this???
We actually never upgraded but started out in XI. This is the only report that fails when running this code base. Our code looks like this.
Dim bytReportStream As Byte()
Dim objRepClientDoc As ReportClientDocument
Dim objPrintOutputController As PrintOutputController '*************************************************************************************************
'Pass the report object and session to function which return the report as a ReportClientDocument
'*************************************************************************************************
objRepClientDoc = GetReport(objCRReport, objEnterpriseSession)
'**********************************
'Export the report as a byte array
'**********************************
objPrintOutputController = objRepClientDoc.PrintOutputController
bytReportStream = objPrintOutputController.Export(CType(objCRReport.RetrieveFormat, CrReportExportFormatEnum)).ByteArray ---This is where the missing parameter error comes
Return bytReportStream
Here is what I'm currently using. Still have a few kinks to work out though.
'-----[ New General Parameter Setup ] ------------
Report.SetParameterValue("ParmName", "Hello World", )
'-----[/ New General Parameter Setup ] ------------
'-----[ New SubReport Parameter Setup ] ------------
Report.SetParameterValue("ParmName", "Hello World", "SubReportName.rpt")
'-----[/ New SubReport Parameter Setup ] ------------
'------------[ Previous General Parameter Setup ]------------------
crParameterFieldDefinitions = Report.DataDefinition.ParameterFieldscrParameterFieldDefinition = crParameterFieldDefinitions.Item("ParmName")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Clear()
crParameterDiscreteValue = New ParameterDiscreteValue
crParameterDiscreteValue.Value = "Hellow World"
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
'------------[/ Previous General Parameter Setup ]------------------
- I'm doing a window forms app instead of web app as in the thread but I get the same error. Using VS.net 2005
System.Runtime.InteropServices.COMException: {"Missing parameter values."}.
Have tried both methods shown in the last post but get the same above error. I'm am trying to run the report and send it straight to the printer (no crystalreportview). Don't see how the second method makes a connection to the ReportDocument. I'm new to this but while debugging or even intelescents doesn't show a parameter value for the parameterfieldname for the reportdocument object. Seems like it should. As you can see below my param name is "SourceFile" as it is in the .rpt file (non-imbeded file).
?myreport.ParameterFields.Item(0)
{CrystalDecisions.Shared.ParameterField}
_DefaultValueDisplayType: 1
AllowCustomValues: True
CurrentValues: Count = 0
DefaultValueDisplayType: DescriptionAndValue {1}
DefaultValues: Count = 0
DefaultValueSortMethod: BasedOnValue {0}
DefaultValueSortOrder: NoSort {0}
DiscreteOrRangeKind: DiscreteValue {0}
EditMask: Nothing
EnableAllowEditingDefaultValue: True
EnableAllowMultipleValue: False
EnableNullValue: False
HasCurrentValue: False
MaximumValue: Nothing
MinimumValue: Nothing
Name: "SourceFile"
ParameterFieldName: "SourceFile"
ParameterType: ReportParameter {0}
ParameterValueKind: StringParameter {4}
ParameterValueType: StringParameter {4}
PromptingType: DiscreteValue {0}
PromptText: Nothing
ReportName: ""
ReportParameterType: ReportParameter {0}
UDefaultValueSortMethod: 0
UDefaultValueSortOrder: 0
UDiscreteOrRangeKind: 0
UParameterType: 0
UParameterValueKind: 4
Here is my code to set up the report
Dim myarraylist As ArrayList = New ArrayList
myarraylist.Add(ACHFileName)
if Not SetValuesForParameterField(myReport, myarraylist) Then
MessageBox.Show("parameter assignment error")
Exit Function
End If
myReport.SetDataSource(ds)
Try
myReport.PrintToPrinter(1, False, 0, 0)
Catch ex As Exception
catch code ....Here is the code to build the parameter
Private Function SetValuesForParameterField(ByVal myReport As ReportDocument, ByVal myArrayList As ArrayList) As Boolean Dim myParameterValues As ParameterValues = New ParameterValues() For Each submittedValue As Object In myArrayList
Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
myParameterDiscreteValue.Value = submittedValue.ToString()
myParameterValues.Add(myParameterDiscreteValue)
Next Dim myParameterFieldDefinitions As ParameterFieldDefinitions = myReport.DataDefinition.ParameterFields
Dim myParameterFieldDefinition As ParameterFieldDefinition
= myParameterFieldDefinitions.Item"SourceFile")
myParameterFieldDefinition.ApplyCurrentValues(myParameterValues)
myReport.DataDefinition.ParameterFields(0).ApplyCurrentValues(myParameterValues)SetValuesForParameterField =
True End Function Works fine if I don't have a parameter.
Any suggestions would be greatly appreciated as I've completly run out of ideas.
Thanks. - Hi Guys,
I had the same problem. I did a little research and I found that you have to define the datasource of the report before the Definition of the parameters.
In VS 2003 the order was different. First we defined the Parameters, and then the datasource.
For me it worked.
Latino- Proposed As Answer bysavy_sr Thursday, November 05, 2009 5:19 PM
- Latino is right. You need to set the datasource in your code before you can start setting the parameter values. Strange, but works !.


