SSRS ReportingService2010 change embedded DataSource to shared DataSource

后端 未结 1 373
广开言路
广开言路 2021-01-19 10:46

I have SQL Server 2008 with SSRS installed on one server and SQL Server 2008 R2 with SSRS installed on a new server. I want to migrate 200+ reports as well as a few shared s

相关标签:
1条回答
  • 2021-01-19 11:46

    So I kept working with the SetItemReferences method and had a brilliant idea that ended up working. The final code I used is below:

    List<ReportService2010.ItemReference> itemRefs = new List<ReportService2010.ItemReference>();
    ReportService2010.DataSource[] itemDataSources = rs2010.GetItemDataSources(catItem.Path);
    
    foreach (ReportService2010.DataSource itemDataSource in itemDataSources)
    {
        ReportService2010.ItemReference itemRef = new ReportService2010.ItemReference();
        itemRef.Name = itemDataSource.Name;
        itemRef.Reference = "/Data Sources/TMS";
        itemRefs.Add(itemRef);
    }
    
    rs2010.SetItemReferences(catItem.Path, itemRefs.ToArray());
    

    The problem was that I was not using the same DataSource name as what was found in the report .rdl file. I was able to determine what the name should be using the GetItemDataSources method. Since this method returns an array and may have more than one item in said array, I looped through it to create multiple ItemReferences if more than one existed though I doubt that happens very often if at all.

    0 讨论(0)
提交回复
热议问题