Reporting Services – SetExecutionParameters

Passing in Read-Only parameters to the Reporting Services Web Service
Just a quick one – I have recently been generating dynamic RDL’s and then using the Reporting Services Web Service to load and render the reports. One little headache I did have was defining the parameters for the reports using the SetExecutionParameters method. One of my parameters is read-only and as such when I tried to pass it to the report I got a nice error back informing me of this.
I spent some time looking around to determine how I pass a read only parameter to a report without any luck. Then it dawned on me . . . just don’t add the parameter to the prameter array . . . and make sure you reduce the array size by one. So my code now loooks like this;
    ReportExecutionWS.ParameterValue[] parameters = new ReportExecutionWS.ParameterValue[3];
    parameters[0] = new ReportExecutionWS.ParameterValue();
    parameters[0].Name = "Version";
    parameters[0].Value = "1.0.0";
    parameters[1] = new ReportExecutionWS.ParameterValue();
    parameters[1].Name = "ReportDate";
    parameters[1].Value = System.DateTime.Now.AddHours(-6).ToString();
    parameters[2] = new ReportExecutionWS.ParameterValue();
    parameters[2].Name = "Resolution";
    parameters[2].Value = "180";
    // We dont need to pass read-only parameters!!!
    //parameters[3] = new ReportExecutionWS.ParameterValue();
    //parameters[3].Name = "ParentId";
    //parameters[3].Value = string.Empty;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s