on 03-18-2010 8:38 PM
Hello - I am customizing a .NET application ou tof box a third party tool. I have created a crystal 2008 report with a parameter for multiple values and it works from crystal report. I can pass discrete value as shown below, how can I make it to pass multiple values like, "ANSTG","TMTG",...
Dim paramValue As CrystalDecisions.Shared.ParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue()
paramValue.Value = "ANSTG"
crReportDocument.SetParameterValue("TG", paramValue)
When I Pass paramValu.Valu = "ANSTG","TMTG", report opens with no data.
what is the correct way of pasing multiple values?
Thanks for the help.
I just recently faced this issue. What you want to do is build a list of string (or int for numbers, or datetime for datetimes or whatever is your crystal parameter's data type). Populate the array, then pass it to the SetParameterValue() funciton. This is my code...pay no attention to my own internal structures. The interesting variable is string [] values
string[] values = new string[(HdlParam.WpfUIParameterElements.First() as ListView).SelectedItems.Count];
int i = 0;
foreach (HdLParameterValueAndDescription HdLElem in (HdlParam.WpfUIParameterElements.First() as ListView).SelectedItems)
{
values<i> = HdLElem.Value.ToString();
i++;
}
ReportCopy.SetParameterValue(HdlParam.crystalParamName, values);
I hope it helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for reply, I modified my code per last reply as follows. I am doing in VB.net.It works fine when I pass single value but generates error for more than one value - "Value does not fall within the expected range". In crystal report parameter is set up as Dynamic, string, Multiple values and not range based. What am I doing wrong?
Dim paramValue As CrystalDecisions.Shared.ParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue()
Dim pField As New CrystalDecisions.Shared.ParameterField
pField = New CrystalDecisions.Shared.ParameterField
pField.Name = "TG"
Dim pFields As New CrystalDecisions.Shared.ParameterFields
pFields = New CrystalDecisions.Shared.ParameterFields
pFields.Add(pField)
pField.CurrentValues.clear()
ParamValue= New CrystalDecisions.Shared.ParameterDiscreteValue()
paramValue.Value = "TMTG"
pField.CurrentValues.Add(ParamValue)
ParamValue=New CrystalDecisions.Shared.ParameterDiscreteValue()
paramValue.Value = "ANSTG"
pField.CurrentValues.Add(ParamValue)
crReportDocument.SetParameterValue("TG", pField)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
replace your code from above with this:
Dim paramValue As CrystalDecisions.Shared.ParameterDiscreteValue
Dim pField As CrystalDecisions.Shared.ParameterField
pField = crReportDocument.ParameterFields.Item("TG")
pField.CurrentValues.clear()
ParamValue= New CrystalDecisions.Shared.ParameterDiscreteValue()
paramValue.Value = "TMTG"
pField.CurrentValues.Add(ParamValue)
ParamValue=New CrystalDecisions.Shared.ParameterDiscreteValue()
paramValue.Value = "ANSTG"
pField.CurrentValues.Add(ParamValue)
Bye
There is also a number of sample apps here:
https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples
A code walk through article here;
http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/2081b4d9-6864-2b10-f49d-918baefc7a23
and finally, don't forget the developer help files:
http://boc.sdn.sap.com/developer/library
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup
Hi,
I think you can do it like this:
C# Code:
ParameterField pField = crReportDocument.ParameterFields["TG"];
pField.CurrentValues.Clear()
ParameterDiscreteValue pDisVal;
pDisVal = new ParameterDiscreteValue();
pDisVal.Value = "ANSTG";
pField.CurrentValues.Add(pDisVal);
pDisVal = new ParameterDiscreteValue();
pDisVal.Value = "ANSTG";
pField.CurrentValues.Add(pDisVal);
...
Good luck
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.