PDA

Click to See Complete Forum and Search --> : [Resolved] Passing Multiple Parameters w/CR & VB 2005


katuil
Aug 23rd, 2007, 04:08 PM
Hello

I have searched for how to pass multiple parameters and have found a way but I still get prompted to enter all but one of the multiple parameters. Which ever parameter I add to my parameter list last is the winner, all others I must enter via the prompt dialog. Here's the code:


Dim paramFields As New CrystalDecisions.Shared.ParameterFields
Dim paramField As New CrystalDecisions.Shared.ParameterField
Dim paramFieldRange As New CrystalDecisions.Shared.ParameterDiscreteValue

Me.crvReportViewer.ReportSource=rptSource

paramField.Name = "@datStart"
paramFieldRange.Value = gdatReportStartDate
paramField.CurrentValues.Add(paramFieldRange)
paramFields.Add(paramField)

MsgBox(paramField.Name.ToString())

paramField.Name = "@datEnd"
paramFieldRange.Value = gdatReportEndDate
paramField.CurrentValues.Add(paramFieldRange)
paramFields.Add(paramField)

paramField.Name = "@txtUser"
paramFieldRange.Value = System.Environment.UserName
paramField.CurrentValues.Add(paramFieldRange)
paramFields.Add(paramField)

Me.crvReportViewer.ParameterFieldInfo = paramFields
Me.crvReportViewer.Refresh()



What I see in the autos window is that paramfields has three items and that all three are exactly the same. I know that this is the issue, but how do I get the paramfields to contain the three different parameters? Does this have something to do with using the ParameterDiscreteValue? Thanks

techgnome
Aug 23rd, 2007, 04:12 PM
put this after you add the parameter, before you set the name on the next one.


paramField = New CrystalDecisions.Shared.ParameterField


What's happening is that you are recylcing the same object, instead of creating new ones.... so each parameter you "add" simply points to the last one by name. By creating a new instance after adding the previous one, the problem should go away.

-tg

katuil
Aug 23rd, 2007, 04:30 PM
Thanks for the obvious. I also found that paramFieldRange was creating a problem as well. I set up three separate parameter field ranges because one was still pushing in the last value into all three parameters.