Using SetItemParameters with rs.exe to modify default values of linked reports

  • Good Day Everyone,

    I would appreciate if anybody could assist me in modifying default values of linked reports (some might be multiple values or NULL) using the SetItemParameters method in a .rss file passed to rs.exe

    Thank you for your time !

    Here is what I try without success:

    Public Sub Main()

    rs.Credentials = System.Net.CredentialCache.DefaultCredentials

    Dim report As String = "/MyFolder/MySubFolder/Test Linked Report"

    Try

    dim myParameter as new ItemParameter()

    myParameter.Name = "LastNameContains"

    dim myDefaultValues(0) as String

    myDefaultValues(0) = "oo"

    myParameter.DefaultValues = myDefaultValues

    rs.SetItemParameters(report, myParameter)

    Catch e As SoapException

    Console.WriteLine(e.Detail.InnerXml.ToString())

    End Try

    End Sub 'Main

    The error I get is :

    error BC30311: Value of type 'Microsoft.SqlServer.ReportingServices2010.ItemParameter' cannot be converted to '1-dimensional array of Microsoft.SqlServer.ReportingServices2010.ItemParameter'.

  • This is probably a bit old, but for future reference. The SetItemParameters method accepts an array of ItemParameters even if you are only changing one, this allows you to set many defaults with one call. What you need to do if create an array of the required length then add your item parameter to this. You can then pass the array to the method.

    Public Sub Main()

    rs.Credentials = System.Net.CredentialCache.DefaultCredentials

    Dim report As String = "/MyFolder/MySubFolder/Test Linked Report"

    Try

    dim myParameters(0) as ItemParameter 'Create 1-item array of ItemParameters

    dim myParameter as new ItemParameter()

    myParameter.Name = "LastNameContains"

    dim myDefaultValues(0) as String

    myDefaultValues(0) = "oo"

    myParameter.DefaultValues = myDefaultValues

    myParameters(0) = myParameter 'Add your item to the array

    rs.SetItemParameters(report, myParameters) 'pass the array

    Catch e As SoapException

    Console.WriteLine(e.Detail.InnerXml.ToString())

    End Try

    End Sub 'Main

    In practise a List is better used for this purpose:

    Public Sub Main()

    rs.Credentials = System.Net.CredentialCache.DefaultCredentials

    Dim report As String = "/MyFolder/MySubFolder/Test Linked Report"

    Try

    dim myParameters as New System.Collections.Generic.List(Of ItemParameter)() 'Create List of itemparameters

    dim myParameter as new ItemParameter()

    myParameter.Name = "LastNameContains"

    dim myDefaultValues(0) as String

    myDefaultValues(0) = "oo"

    myParameter.DefaultValues = myDefaultValues

    myParameters.Add(myParameter) 'Add your item to the list

    rs.SetItemParameters(report, myParameters.ToArray()) 'pass the array

    Catch e As SoapException

    Console.WriteLine(e.Detail.InnerXml.ToString())

    End Try

    End Sub 'Main

  • Hello 'Get me?'

    It is never too late to answer a post and I really appreciate your help on this one. I've successfully tested the code you provided, this is just great.

    Thanks again and have a good one !

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply