Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Prarmeters passed via VB.NET 1

Status
Not open for further replies.

Juice05

Programmer
Dec 4, 2001
247
US
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.
 
try this, this works fine

Dim paramFields As ParameterFields = New ParameterFields
Dim Param As ParameterField
Dim dcParam As ParameterDiscreteValue
Dim ParamName As String

If ParameterCount > 0 Then
Dim i As Integer = 1

For i = 1 To ParameterCount

Param = New ParameterField
Param.ParameterFieldName = ParameterName(i)

dcParam = New ParameterDiscreteValue
dcParam.Value = ParameterValue(i)

Param.CurrentValues.Add(dcParam)
paramFields.Add(Param)
Next

cvwMain.ParameterFieldInfo = paramFields

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top