SSRS ReportingService2010 change embedded DataSource to shared DataSource

别说谁变了你拦得住时间么 提交于 2019-12-01 18:29: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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!