I am adding crystal reports to my VB.NET application using SQL Server 2000 Stored Procedures and have ran into a snag. I am able to create reports with one parameter and they work perfectly. However, I am having a problem figuring out how to handle reports with multiple parameters.
The perfect solution would be creating a way to have the amount of parameters within a report, parameter names and the values to a function within the form that the report viewer resides on. Then with a simple loop the values of the report would be set and then view the report. This is what I have so far but can't seem to get it to work.
Public ParameterCount As Integer
Public ParameterName(10) As String
Public ParameterValue(10) As String
Dim ParameterFields As New CrystalDecisions.Shared.ParameterFields
Dim ParameterField As New CrystalDecisions.Shared.ParameterField
Dim ParameterRangeValue As New CrystalDecisions.Shared.ParameterDiscreteValue 'ParameterRangeValue
If ParameterCount > 0 Then
Dim i As Integer = 1
For i = 1 To ParameterCount
ParameterField.ParameterFieldName = ParameterName(i)
ParameterRangeValue.Value = ParameterValue(i)
ParameterField.CurrentValues.Add(ParameterRangeValue)
ParameterFields.Add(ParameterField)
Next
cvwMain.ParameterFieldInfo = ParameterFields
End If
This works for single parameter reports. If I try this on reports with more than one parameter, only the last parameter in the list gets set. I receive a pop up asking for the parameters to be entered for the other parameters.
I have searched and searched the Internet and can't find any samples of this anywhere. Any help would be greatly appreciated.
The perfect solution would be creating a way to have the amount of parameters within a report, parameter names and the values to a function within the form that the report viewer resides on. Then with a simple loop the values of the report would be set and then view the report. This is what I have so far but can't seem to get it to work.
Public ParameterCount As Integer
Public ParameterName(10) As String
Public ParameterValue(10) As String
Dim ParameterFields As New CrystalDecisions.Shared.ParameterFields
Dim ParameterField As New CrystalDecisions.Shared.ParameterField
Dim ParameterRangeValue As New CrystalDecisions.Shared.ParameterDiscreteValue 'ParameterRangeValue
If ParameterCount > 0 Then
Dim i As Integer = 1
For i = 1 To ParameterCount
ParameterField.ParameterFieldName = ParameterName(i)
ParameterRangeValue.Value = ParameterValue(i)
ParameterField.CurrentValues.Add(ParameterRangeValue)
ParameterFields.Add(ParameterField)
Next
cvwMain.ParameterFieldInfo = ParameterFields
End If
This works for single parameter reports. If I try this on reports with more than one parameter, only the last parameter in the list gets set. I receive a pop up asking for the parameters to be entered for the other parameters.
I have searched and searched the Internet and can't find any samples of this anywhere. Any help would be greatly appreciated.