Wednesday, March 21, 2012

How to use set_ParameterField to pass a parameter to a report

I have to pass a dateTime to a Report
I try to use this code

AxCrystalReport1.set_ParameterFields(0, "START;CDate(28/04/2005 0.00.00);True")
or this
AxCrystalReport1.set_ParameterFields(0, "START;CDate(28/04/2005);True")
and also
AxCrystalReport1.set_ParameterFields(0, "START;28/04/2005;True")

But in all the case report doesn't appear to video...

I'm sure that there isn't any error in the rest of code , the problem is on this line !!

where's my mistake?
Please
Help me...If you are using Vb.Net then use the following code

'Declare these 3 objects
Dim p1 As New ParameterFields
Dim p2 As New ParameterField
Dim p3 As New ParameterDiscreteValue

'Now set the name of your parameter to the 'ParameterField' object

p2.ParameterFieldName = "Header" ' replace "Header" with the name of your Parameter

'Now set the needed value to the 'ParameterDiscreteValue' Object
p3.Value = "Country Report2"
'Now add that value to ParameterField Object
p2.CurrentValues.Add(p3)
'Bind the ParameterField obj to ParameterFields obj
p1.Add(p2)
'Now set the ParameterFields obj to report
frm1.crv1.ParameterFieldInfo = p1 'Here crv1 is the crystal report Obj

Think that works for you|||Thanks I try also your solution ... it' s works well!!

but my initial problem was also passing date ( with time eventually) parameter...
And yesterday night I 've find a good solution ... I just substitute Cdate with Date and the passing Date parameter goes well!!

Anyway See ya & thks a lot!!!|||how to pass multiple parameter with this method?

i was using

Rep.SetParameterValue("n_socio", nSocio)
Rep.SetParameterValue("tipo_socio", sTipoSocio)
Rep.SetParameterValue("dni", dni)
....

to pass multiple parameters to crystal reports but when i upgrade CR from Ver. 9 to Ver. 10 this method don't work anymore.

please help...sql

No comments:

Post a Comment