all groups > sql server reporting services > september 2004 >
You're in the

sql server reporting services

group:

ReportParameters setting ValidValues


ReportParameters setting ValidValues bob
9/6/2004 11:45:01 PM
sql server reporting services: Hi,
I am trying to pass parameters using Reporting service web service. Here is
the code I used. I feel I am not passing validvalues properly. Can anyone
help me. Thanks in advance.

ReportingService rs = new ReportingService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
ReportParameter[] repParameters =
rs.GetReportParameters(@"/passdownreport/Report1", null, false, null, null);
if(repParameters != null)

{
// Prepare report parameter.
ParameterValue[] parameters = new
ParameterValue[repParameters.Length];

for(int k=0; k<=repParameters.Length-1;k++)
{
if(repParameters[k].Name == "EmployeeNames")
{
parameters[k] = new ParameterValue();
parameters[k].Name = "EmployeeNames";
parameters[k].Value = "john,mary,scott";

}

repParameters[k].ValidValues.SetValue(parameters[k].value,k);
}

rs.SetReportParameters(@"/passdownreport/Report1",repParameters);
===================Thanks===============

RE: ReportParameters setting ValidValues bob
9/8/2004 3:39:06 AM
Would like to elaborate the error I am getting.

Near line mentioned below, it is giving an error like "Object reference not
set to an instance of an object".
rs.SetReportParameters(@"/passdownreport/Report1",repParameters);

When I debug, Valid values is coming as undefined.

I am new to Reporting services programming, and I tried all possible options
from my side. Please help me if anu one of you know, where I went wrong.

Thanks,
bob

[quoted text, click to view]
Re: ReportParameters setting ValidValues fzuma NO[at]SPAM yahoo.com
9/8/2004 11:43:30 AM
Bob,

I have run into something similiar to this using DefaultValues. If
the original report creation did not have a specified DefaultValue for
a report parameter I can not access it or set a value to it. If a
DefaultValue was established at report creation then I could do what I
wanted.

So I'm guessing you aren't getting access to ValidValues because you
didn't specify any on the original report creation. It's worth a look,
I could be way off on your problem, it just appears the same as my
problem when the value comes up as <undefined>. I know of no solution
and am trying to get a response from a MS guy. Hope this helps
understand your problem a bit more.

Frank

[quoted text, click to view]
Re: ReportParameters setting ValidValues bob
9/9/2004 12:03:02 AM
Hi Frank,

Thanks for your help.

I have created a new report with default parameter/value in it. And I used
this report with following code. Still I am facing the same problem.

Is there any ValidValues option in report creation?

bob.

[quoted text, click to view]
Re: ReportParameters setting ValidValues fzuma NO[at]SPAM yahoo.com
9/9/2004 8:09:36 AM
I was referring to DefaultValues in my case, because I was trying to
retrieve the DefaultValues not ValidValues. In your case, I would
assume you need to add Available Values in the Report Parameter you
are trying to retrieve ValidValues from. Again, I am just taking a
stab here, and I am not perfectly sure, but it's worth a try. I don't
see any MVPs knocking either of us over with answers to our questions.
Good Luck.

Frank

[quoted text, click to view]
Re: ReportParameters setting ValidValues fzuma NO[at]SPAM yahoo.com
9/9/2004 9:09:17 AM
Ok, I believe I've got the answer to both our problems...this may need
personal tweeking...the main line is the if statement...check it out:

foreach (ReportParameter paramRpt in aryReportParameters)
{
if (paramRpt.ValidValues == null)
paramRpt.ValidValues = new string[1];

paramRpt.ValidValues.SetValue(value, 0);
}


[quoted text, click to view]
Re: ReportParameters setting ValidValues bob
9/10/2004 12:21:04 AM
Hi Kalos,

Thank you very much for your help.

It wokrd for me but I had to make little modification, as mentioned below.
Because ValidValues does not accept String[], so I coded like this and it is
working.

ValidValue v = new ValidValue();
v.Label = "LastName";
v.Value = "Abbas";
foreach (ReportParameter paramRpt in repParameters)
{
if (paramRpt.ValidValues == null)
paramRpt.ValidValues = new ValidValue[1];

paramRpt.ValidValues[0] = v;

}

Regards,
bob



[quoted text, click to view]
AddThis Social Bookmark Button