Programatically set report datasource RRS feed

  • Question

  • I have a datasource created in my reporting server under a folder called DataSources.

    I am uploading .rdl files using a console application. Is there any way to set the datasource of the uploaded .rdl programatically to datasource available in dataSources folder.

    I am using reportingService webservice and C# to upload .rdls.


    Thursday, November 6, 2014 9:29 AM


All replies

  • Hello Mohan,

    You can do that with the ReportingService2010.SetItemDataSources Method

    See ReportingService2010 Class for all methods & properties.

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Thursday, November 6, 2014 9:44 AM
  • Hopefully this is helpful:

    using GetPropertiesSample.ReportService2010;
    using System.Collections.Generic; //<== required for LISTS

    namespace GetPropertiesSample
        class Program
            static void Main(string[] args)


            private static void ResetTheDataSource_for_a_Report()
                //from: http://stackoverflow.com/questions/13144604/ssrs-reportingservice2010-change-embedded-datasource-to-shared-datasource

                ReportingService2010 rs = new ReportingService2010();
                rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
                string reportPathAndName = "/0_Contacts/207_Practices_County_CareManager_Role_ContactInfo";
                List<ReportService2010.ItemReference> itemRefs = new List<ReportService2010.ItemReference>();
                ReportService2010.DataSource[] itemDataSources = rs.GetItemDataSources(reportPathAndName);

                foreach (ReportService2010.DataSource itemDataSource in itemDataSources)
                    ReportService2010.ItemReference itemRef = new ReportService2010.ItemReference();
                    itemRef.Name = itemDataSource.Name;
                    itemRef.Reference = "/DataSources/SharedDataSource_DB2_CRM";

                rs.SetItemReferences(reportPathAndName, itemRefs.ToArray());

    Sunday, March 27, 2016 4:08 PM