ReportingServices SetReportDataSources异常操作,您正在尝试项错误

本文关键字:错误 SetReportDataSources 异常 操作 ReportingServices | 更新日期: 2023-09-27 18:11:29

我只是想设置一个共享数据源。我一直得到异常

此项目类型不允许对项目进行操作。

也许我有什么东西混在一起,但我不能确定。

filepath=/Base/Vendor(报告的完整路径);
数据源= IBBase

 public static void UpdateDataSource(string filepath, string datasource)
    {
        ReportingService rs = new ReportingService();
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
        ServicesReport.DataSourceReference reference = new ServicesReport.DataSourceReference();
        reference.Reference = filepath;
        ServicesReport.DataSource[] dataSources = new ServicesReport.DataSource[1];
        ServicesReport.DataSource ds = new ServicesReport.DataSource();
        ds.Item = (ServicesReport.DataSourceDefinitionOrReference)reference;
        ds.Name = datasource;
        dataSources[0] = ds;
        try
        {
            rs.SetReportDataSources(filepath, dataSources);
            Console.WriteLine("New reference set for the report.");
        }
        catch (SoapException e) 
        {
            Console.WriteLine(e.Detail.InnerXml.ToString());
        }
    }

ReportingServices SetReportDataSources异常操作,您正在尝试项错误

这个Connect调用使用SetItemDataSources方法报告相同的错误代码:http://connect.microsoft.com/SQLServer/feedback/details/318868/ssrs-2005-sp2-setitemdatasource-web-method-bug#details.

微软给出的答案的底线是数据源名称不能是任意的。它必须与与当前报告相关联的现有报告相匹配。您是否可以检查报表服务器上的报表配置是否与您在代码中尝试连接的数据源完全相同?

如果不是,那么您已经找到了问题的可能原因。

这很有帮助。这是我的工作…

//************ Associate the shared datasource to the report ************
//Step 1 - Get the datasource for the report
DataSource[] _currReportDataSource = 
_ssrsService.GetItemDataSources(report.Path);
//Step 2 - Create a reference to the shared datasource for the tenent
SSRS_Service.DataSourceReference _dsRef = new DataSourceReference();
_dsRef.Reference = <Path to the datasource>     //Usually like "/Folder Name/Datasource Name"
//Step 3 - Create a new datasource object with reference to the shared     datasource for the tenent
DataSource _newReportDataSource = new DataSource();
_newReportDataSource.Item = _dsRef;     //this line sets the reference of the object to the shared datasource
_newReportDataSource.Name = _currReportDataSource[0].Name;      //we will use the current name of the report as it is exists now.  Defaultly named as "DataSource1"
//Step 4 - Load the datasource object (with reference to shared datasource) to a temp array as the SetItemDataSources method requires an array.
DataSource[] dsArray = new DataSource[1];
dsArray[0] = _newReportDataSource;
_ssrsService.SetItemDataSources(report.Path, dsArray);      //Set the datasource for the report to the shared datasource