Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

Problem with passing multiple discrete values to a parameter

$
0
0

I am struggling to get the passing of multiple discrete values to a parameter field to work. Single discrete and single ranged parameters are working fine, but despite trying all examples I can find (and there's not many) I can't get it to work. Can anyone see what is going wrong in my code below, please?

 

This is running against CR Server 2013 and it is lines 36-45 that are the issue. The code steps through the parameters found in the report and looks for URL/Form values with matching names. The multiple value capable fields are supplied with comma delimited lists of strings in the URL/Form values.

 

Private Sub DatabaseLogon_unmanagedRAS()  Dim mySampleReportPath As String = Request("rpt__rpt")  Dim path As Object = CType(mySampleReportPath, String)  Dim rptFile As String = path.Substring(8)  Dim databaseUserName As String = Request("rpt__un")  Dim databasePassword As String = Request("rpt__pw")  Dim rcd As New ReportClientDocumentClass()  Dim pfld As String  Dim pfldName As String          Dim crMainReportParameterFields As Fields  Dim crField As Field  Dim arrKeys() As String  Dim newVal As ParameterDiscreteValue   Dim crDiscreteVal As CrystalDecisions.Shared.ParameterDiscreteValue   rcd.ReportAppServer = "localhost:6420"   rcd.Open(rptFile, 0)   rcd.DatabaseController.logon(databaseUserName, databasePassword)   crMainReportParameterFields = rcd.DataDefinition.ParameterFields   For Each crField In crMainReportParameterFields    pfldName = crField.Name.ToString    Try     Select Case crField.ValueRangeKind      'Ranged parameter.      Case 0       Dim crRangeVal As ParameterFieldRangeValue = New ParameterFieldRangeValue()       pfld = Request(pfldName)       arrKeys = pfld.Split("|")        crRangeVal.BeginValue = arrKeys(0)       crRangeVal.EndValue = arrKeys(1)       crRangeVal.LowerBoundType = RangeBoundType.BoundInclusive       crRangeVal.UpperBoundType = RangeBoundType.BoundInclusive       rcd.DataDefController.ParameterFieldController.SetCurrentValue("", pfldName, crRangeVal)       'Discrete parameter.      Case 1       If crField.AllowMultiValue Then ' multiple values        Dim crParameterValues As ParameterValues = New ParameterValues()        pfld = Request(pfldName)        arrKeys = pfld.Split(",")         For Each multiVal As String In arrKeys           crDiscreteVal = New CrystalDecisions.Shared.ParameterDiscreteValue()          crDiscreteVal.value = multiVal.toString()          crField.CurrentValues.Add(crDiscreteVal)        Next       Else ' single value        crDiscreteVal = New CrystalDecisions.Shared.ParameterDiscreteValue()        crDiscreteVal.Value = Request(pfldName)        rcd.DataDefController.ParameterFieldController.SetCurrentValue("", pfldName, crDiscreteVal)        End If     End Select    Catch ex As Exception     Response.Write("<b><u>The report viewer has encountered an error:</u></b><br><br>")     Response.Write(ex.Message)     Response.Write("Stack Trace: " & vbCrLf & ex.StackTrace)     rcd.Close()    Finally      'do cleanup    End Try   Next   'Debug_showParams(crMainReportParameterFields)     myCrystalReportViewer.ReportSource = rcd     myCrystalReportViewer.HasRefreshButton = true    End Sub

Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>