Hi All,< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
I am using a windows form to display a CR viewer control. I then programmatically set the reportsource to a report I have defined. The report has a parameter that I want to use like a where clause in the selection of the data. For some reason I think the parameter has no effect on the report, meaning it doesn’t matter what I value I give it I get a complete listing of data in the report.
Now I am a newb when it comes to CR.Net so it doesn’t surprise me this doesn’t work. I guess what I don’t understand is how do I display only a subset of the data in my database. What I want to be able to do is something like a SQL where clause. At any rate here is what I have that doesn’t work. Again the report displays, its just filtered.
ParameterField pf = new ParameterField();
ParameterFields pfs = new ParameterFields();
ParameterDiscreteValue pdv = new ParameterDiscreteValue();
pf.Name = "round";
pdv.Value = this.cbRace.Text;
pf.CurrentValues.Add(pdv);
pfs.Add(pf);
this.crvTeams.ParameterFieldInfo = pfs;
this.crvTeams.RefreshReport();
The report has a parameter defined that is a discrete value and has a type of sting. The name is “round”.
Can anyone tell me what I am not doing, or doing wrong
Thanks for any help!
< xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />

Parameter used to create a CR report
burrrrrhaannnn
Now I feel lame... I dont any see anything in your code I am not doing... with the exception of you have two vaules. Am I missing something
Chad
Eva Pierce Monsen
Perhaps this will help. slightly different than yours, as I'm getting the params from a stored procedure, but that shouldn't matter much. Looking at this you should be able to find out what you are missing in yours.
Carl
Dim paramFields As New CrystalDecisions.Shared.ParameterFields()
Dim paramField As New CrystalDecisions.Shared.ParameterField()
Dim discreteVal As New CrystalDecisions.Shared.ParameterDiscreteValue()
Dim paramField2 As New CrystalDecisions.Shared.ParameterField()
Dim discreteVal2 As New CrystalDecisions.Shared.ParameterDiscreteValue()
paramField.ParameterFieldName = "@EnterBeginningDate"
Dim gva As DateTime = DateTime.Parse(gv)
discreteVal.Value = gva
paramField.CurrentValues.Add(discreteVal)
paramFields.Add(paramField)
paramField2.ParameterFieldName = "@EnterEndingDate"
Dim gv1a As DateTime = DateTime.Parse(gv1)
discreteVal2.Value = gv1a
paramField2.CurrentValues.Add(discreteVal2)
paramFields.Add(paramField2)
' Set the parameter fields collection into the viewer control.
CrystalReportViewer1.ParameterFieldInfo = paramFields
cwolf
Well I got it to work.
This is what I did:
Use a function from the examples.
private void SetCurrentValuesForParameterField(ReportDocument reportDocument, string round){
ParameterValues currentParameterValues = new ParameterValues(); ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();parameterDiscreteValue.Value = round;
currentParameterValues.Add(parameterDiscreteValue);
ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields; ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[PARAMETER_FIELD_NAME];parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
}
I also had to tell the report to use the input in a where clause.
Hope it helps
Chad