Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Adding a datasource to a report programatically fa

Author  Topic 

anthony_orr
Starting Member

1 Post

Posted - 2010-05-21 : 13:42:25
I'm using VS2005, and SSRS 2008. RSWS is the reporting server web service, using ReportingService2005.

Code:

RSWS.DataSourceReference dataSourceRef = new RSWS.DataSourceReference();
dataSourceRef.Reference = dsItem.Path;

RSWS.DataSource ds = new RSWS.DataSource();
ds.Item = dataSourceRef;
ds.Name = dsItem.Name;

RSWS.DataSource[] dsArray = new RSWS.DataSource[] { ds };

mSvc.SetItemDataSources(string.Format("{0}/{1}", sPath, sReportName), dsArray);

When adding the data source to the report, it fails with the folowing exception:

System.Web.Services.Protocols.SoapException: The data source 'MainDataSource' cannot be found. ---> Microsoft.ReportingServices.Diagnostics.Utilities.DataSourceNotFoundException: The data source 'MainDataSource' cannot be found.
at Microsoft.ReportingServices.WebServer.ReportingService2005Impl.SetItemDataSources(String Item, DataSource[] DataSources)
at Microsoft.ReportingServices.WebServer.ReportingService2005.SetItemDataSources(String Item, DataSource[] DataSources)

I have tried everything, and cannot get this to work properly. All pf the examples I have seen don't mention the "Name" property of the Datasource object. If I exclude that, an exception is thrown telling me I did not include the required property "Name". If I remove the name of the datasource from the dataSourceRef.Reference preperty, an Illegal Operation exception is thrown.
   

- Advertisement -