crystal reports parameter
-
:~ I am sorry but i am posting this again because I didn't get reply for my problem if any one can help me please. I want to pass parameters to crystal reports but i dont know how i found example on microsoft site // Declare variables needed to pass the parameters // to the viewer control. ParameterFields paramFields = new ParameterFields (); ParameterField paramField = new ParameterField (); ParameterDiscreteValue discreteVal = new ParameterDiscreteValue (); ParameterRangeValue rangeVal = new ParameterRangeValue (); // The first parameter is a discrete parameter with multiple values. // Set the name of the parameter field, this must match a // parameter in the report. paramField.ParameterFieldName = "Customer Name"; // Set the first discrete value and pass it to the parameter. discreteVal.Value = "AIC Childrens"; paramField.CurrentValues.Add (discreteVal); // Set the second discrete value and pass it to the parameter. // The discreteVal variable is set to new so the previous settings // will not be overwritten. discreteVal = new ParameterDiscreteValue (); discreteVal.Value = "Aruba Sport"; paramField.CurrentValues.Add (discreteVal); // Add the parameter to the parameter fields collection. paramFields.Add (paramField); // The second parameter is a range value. The paramField variable // is set to new so the previous settings will not be overwritten. paramField = new ParameterField (); // Set the name of the parameter field, this must match a // parameter in the report. paramField.ParameterFieldName = "Customer ID"; // Set the start and end values of the range and pass it to the // parameter. rangeVal.StartValue = 42; rangeVal.EndValue = 72; paramField.CurrentValues.Add (rangeVal); // Add the second parameter to the parameter fields collection. paramFields.Add (paramField); // Set the parameter fields collection into the viewer control. crystalReportViewer1.ParameterFieldInfo = paramFields; Problem is that when i write this code for my reports in c# I am not finding "paramField.ParameterFieldName" in intellisence. I am seeing some other methods but they gives error. I am using V.S. 2003 and crystal report 9.0 Please can any one tell me why its happening I would be obliged. Naveed Kamboh
-
:~ I am sorry but i am posting this again because I didn't get reply for my problem if any one can help me please. I want to pass parameters to crystal reports but i dont know how i found example on microsoft site // Declare variables needed to pass the parameters // to the viewer control. ParameterFields paramFields = new ParameterFields (); ParameterField paramField = new ParameterField (); ParameterDiscreteValue discreteVal = new ParameterDiscreteValue (); ParameterRangeValue rangeVal = new ParameterRangeValue (); // The first parameter is a discrete parameter with multiple values. // Set the name of the parameter field, this must match a // parameter in the report. paramField.ParameterFieldName = "Customer Name"; // Set the first discrete value and pass it to the parameter. discreteVal.Value = "AIC Childrens"; paramField.CurrentValues.Add (discreteVal); // Set the second discrete value and pass it to the parameter. // The discreteVal variable is set to new so the previous settings // will not be overwritten. discreteVal = new ParameterDiscreteValue (); discreteVal.Value = "Aruba Sport"; paramField.CurrentValues.Add (discreteVal); // Add the parameter to the parameter fields collection. paramFields.Add (paramField); // The second parameter is a range value. The paramField variable // is set to new so the previous settings will not be overwritten. paramField = new ParameterField (); // Set the name of the parameter field, this must match a // parameter in the report. paramField.ParameterFieldName = "Customer ID"; // Set the start and end values of the range and pass it to the // parameter. rangeVal.StartValue = 42; rangeVal.EndValue = 72; paramField.CurrentValues.Add (rangeVal); // Add the second parameter to the parameter fields collection. paramFields.Add (paramField); // Set the parameter fields collection into the viewer control. crystalReportViewer1.ParameterFieldInfo = paramFields; Problem is that when i write this code for my reports in c# I am not finding "paramField.ParameterFieldName" in intellisence. I am seeing some other methods but they gives error. I am using V.S. 2003 and crystal report 9.0 Please can any one tell me why its happening I would be obliged. Naveed Kamboh
I haven't been at CP for a while. Hi everyone. Naveed, if you search through previous post I bet this question was answer multiple times. I quickly pulled up a file using Google desktop search and I found a function that I used on a previous project. Take a look at this. It might help you:
private void SetParameter(string name, string val)
{
ParameterFieldDefinitions paramFlds = report.DataDefinition.ParameterFields; // Get the parameter fields
ParameterFieldDefinition paramFld = paramFlds[name]; // Get a specific one
ParameterDiscreteValue discreteValue = new ParameterDiscreteValue(); // Create a value type
ParameterValues paramValues = paramFld.CurrentValues; // Get the collection of current values
paramValues.Clear(); // Clear the current
discreteValue.Value = val; // Set the value
paramValues.Add(discreteValue); // Add the value type
paramFld.ApplyCurrentValues(paramValues); // Apply the parameters to the document
}Alex Korchemniy