locked
Get all shared data sources programatically using the web service? RRS feed

  • Question

  • Similar to this post, I need to modify shared data source(s) on our SSRS 2008 server.

    http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/b9874ec7-f2da-40a1-9dc1-3523c0e81741

    However, I need to take it one step further -- by looping through all the shared datasources defined on the server, and programatically modifying the ones that meet some certain criteria.  I want to do this dynamically, without hardcoding the data source names....so I need a method to retrieve all the shared datasources defined on the server.  The ReportingService2005.GetItemDataSources works for a report, but not for the server itself (as far as I can tell).

    Is there a method or approach to programatically retrieve the shared datasources of the server?

    Thanks

    -Mark

     

    Friday, March 11, 2011 11:06 PM

Answers

  • You can retrieve the all the datasources in the server using items returned by listchildren method. Then call your custom routine passting the path and name property of the item (which reflects a shared datasrouce). Below code snippet may help you

    Dim items As CatalogItem() = Nothing
    items = rs.ListChildren("/", True)
    For Each reportItem As CatalogItem In items
    	' if the type is a shared data source
    	If reportItem.Type = ItemTypeEnum.DataSource Then
    		' The code to get the set the datasource properties goes here
    		' use reportItem.Path and reportItem.Name to get location in 
    		' report server
    		Console.WriteLine(reportItem.Path & "\" & reportItem.Name)
    	End If
    Next
    
    

    Hope this helps 


    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.

    BH

    • Proposed as answer by Olaf HelperMVP Saturday, March 12, 2011 9:48 AM
    • Marked as answer by markoos1 Monday, March 14, 2011 3:53 PM
    Saturday, March 12, 2011 9:02 AM

All replies

  • You can retrieve the all the datasources in the server using items returned by listchildren method. Then call your custom routine passting the path and name property of the item (which reflects a shared datasrouce). Below code snippet may help you

    Dim items As CatalogItem() = Nothing
    items = rs.ListChildren("/", True)
    For Each reportItem As CatalogItem In items
    	' if the type is a shared data source
    	If reportItem.Type = ItemTypeEnum.DataSource Then
    		' The code to get the set the datasource properties goes here
    		' use reportItem.Path and reportItem.Name to get location in 
    		' report server
    		Console.WriteLine(reportItem.Path & "\" & reportItem.Name)
    	End If
    Next
    
    

    Hope this helps 


    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.

    BH

    • Proposed as answer by Olaf HelperMVP Saturday, March 12, 2011 9:48 AM
    • Marked as answer by markoos1 Monday, March 14, 2011 3:53 PM
    Saturday, March 12, 2011 9:02 AM
  • Yup!  That's it, thanks.  Here's the same code in C#.

     

    CatalogItem[] items = rs.ListChildren("/", true);
          foreach(CatalogItem reportItem in items) {
            if (reportItem.Type == ItemTypeEnum.DataSource)
            {
              Console.WriteLine("Found Datasource " + reportItem.Path + "\\" + reportItem.Name + ".");
            }
          }
    
    -Mark

     

    Monday, March 14, 2011 3:52 PM