August 28, 2012 at 4:38 am
I’m sorry this maybe a very amateur question but I’m a beginner in programming
Scenario:
An existing report has two parameters int SnapshotId = 0
And string Department = “IT”,
Change Department = “Finance”
I managed to get the report parameters of a specified report, but how do I now change the Department parameter
private ReportingService2005 _rs = new ReportingService2005();
private ReportExecutionService _rsExec = new ReportExecutionService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials; _rsExec.
Credentials = System.Net.CredentialCache.DefaultCredentials;
string report = cboReports.Text; //report path
bool forRendering = false;
string historyID = null;
ParameterValue[] values = null; //
DataSourceCredentials[] credentials = null;
ReportParameter[] parameters = null;
parameters = _rs.GetReportParameters(report, historyID, forRendering, values, credentials);
August 28, 2012 at 7:51 am
I worked it out with the help of a colleague
in the hope that it may help others below is my code
string report = cboReports.Text; //report path
bool forRendering = false;
string historyID = null;
ParameterValue[] values = null; //
DataSourceCredentials[] credentials = null;
ReportParameter[] parameters = null;
parameters = _rs.GetReportParameters(report, historyID, forRendering, values, credentials);
if (parameters != null)
{
foreach (parameter in parameters)
{
if (parameter.Name == "Department")
{
if (parameter.DefaultValues == null)
{
parameter.DefaultValues = newstring[] { "Finance" };
_rs.SetReportParameters(report, parameters);
}
else
{
parameter.DefaultValues.SetValue("Finance" , 0);
_rs.SetReportParameters(report, parameters);
}
}
}
}
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply