#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    ReportingService2010.SetItemParameters Method


    Greetings Need some help and thanks in advance!!
    I have a SSRS report deployed on a report server (native mode) and now I'm developing a SSIS package to "interact" with this report, so in my SSIS "Script Task" I have the following code segment:

    public void Main()
    {
    ReportingService2010 rs = new ReportingService2010();
    rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
    rs.Url = http://somesever:8080/ReportServer_SQL01/reportservice2010.asmx?wsdl;
    string report = "/ABM_REPORTS/Master/SSIS Linked Monthly Report";
    bool forRendering = false;
    string historyID = null;
    ParameterValue[] values = null;
    DataSourceCredentials[] credentials = null;
    ItemParameter[] parameters = null;
    int counter = 0;
    try
    {
    parameters = rs.GetItemParameters(report, historyID, forRendering, values, credentials);
    Console.WriteLine("parameters[0].Name = " + parameters[0].Name);
    Console.WriteLine("parameters[0].DefaultValues = " + parameters[0].DefaultValues);
    Console.WriteLine("parameters[1].Name = " + parameters[0].Name);
    Console.WriteLine("parameters[1].DefaultValues = " + parameters[0].DefaultValues);

    // NEED Help !!!
    rs.SetItemParameters(report, parameters[0].DefaultValues.SetValue("My_DB_Name", ???? ));
    Console.WriteLine("NOW parameters[0].DefaultValues = " + parameters[0].DefaultValues);
    }
    catch (SoapException e)
    {
    Console.WriteLine(e.Detail.InnerXml.ToString());
    }
    Dts.TaskResult = (int)ScriptResults.Success;
    }

    What I'm trying to do is to assign a default value to the first parameter of this Report HOWEVER I'm having a hard time figuring out what should be the arguments for the method SetItemParameters, just couldn't pass complier

    If I coment-out the 'Set' and execute the task the output looks like:
    parameters[0].Name = databaseName
    parameters[0].DefaultValues =
    parameters[1].Name = orderProcessDate
    parameters[0].DefaultValues =

    But with the 'Set' I always got ERROR as "The best overloaded method match for ...... has some invalid arguments"
    In particular,
    rs.SetItemParameters(report, parameters[0].DefaultValues.SetValue("My_DB_Name", 1 ));

    Argument '2': cannot convert from 'void' to 'ST_a6ff246c0xxxc.csproj.ReportService2010.ItemParameter[]'

    But if I substitute the "1" with parameters[0] it's the same thing

    Can someone give me some tips/clues/comments -- anything would be helpful and greatly appreciated!!!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0
    Change your rs.SetItemParameters section to be something like this:

    parameters.SetValue("value",0);
    rs.SetItemParameters(report, parameters);


    The reason for this is because you have to tell it what index in the ItemParameter array to place the value.

    Hope this isn't too late, but I just wasted almost an hour researching this very same issue so thought I'd post the answer in order to help anyone else out.



    Originally Posted by mikehe
    Greetings Need some help and thanks in advance!!
    I have a SSRS report deployed on a report server (native mode) and now I'm developing a SSIS package to "interact" with this report, so in my SSIS "Script Task" I have the following code segment:

    public void Main()
    {
    ReportingService2010 rs = new ReportingService2010();
    rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
    rs.Url = http://somesever:8080/ReportServer_SQL01/reportservice2010.asmx?wsdl;
    string report = "/ABM_REPORTS/Master/SSIS Linked Monthly Report";
    bool forRendering = false;
    string historyID = null;
    ParameterValue[] values = null;
    DataSourceCredentials[] credentials = null;
    ItemParameter[] parameters = null;
    int counter = 0;
    try
    {
    parameters = rs.GetItemParameters(report, historyID, forRendering, values, credentials);
    Console.WriteLine("parameters[0].Name = " + parameters[0].Name);
    Console.WriteLine("parameters[0].DefaultValues = " + parameters[0].DefaultValues);
    Console.WriteLine("parameters[1].Name = " + parameters[0].Name);
    Console.WriteLine("parameters[1].DefaultValues = " + parameters[0].DefaultValues);

    // NEED Help !!!
    rs.SetItemParameters(report, parameters[0].DefaultValues.SetValue("My_DB_Name", ???? ));
    Console.WriteLine("NOW parameters[0].DefaultValues = " + parameters[0].DefaultValues);
    }
    catch (SoapException e)
    {
    Console.WriteLine(e.Detail.InnerXml.ToString());
    }
    Dts.TaskResult = (int)ScriptResults.Success;
    }

    What I'm trying to do is to assign a default value to the first parameter of this Report HOWEVER I'm having a hard time figuring out what should be the arguments for the method SetItemParameters, just couldn't pass complier

    If I coment-out the 'Set' and execute the task the output looks like:
    parameters[0].Name = databaseName
    parameters[0].DefaultValues =
    parameters[1].Name = orderProcessDate
    parameters[0].DefaultValues =

    But with the 'Set' I always got ERROR as "The best overloaded method match for ...... has some invalid arguments"
    In particular,
    rs.SetItemParameters(report, parameters[0].DefaultValues.SetValue("My_DB_Name", 1 ));

    Argument '2': cannot convert from 'void' to 'ST_a6ff246c0xxxc.csproj.ReportService2010.ItemParameter[]'

    But if I substitute the "1" with parameters[0] it's the same thing

    Can someone give me some tips/clues/comments -- anything would be helpful and greatly appreciated!!!

IMN logo majestic logo threadwatch logo seochat tools logo