Updating Shared data source connection string programmatically
hi all,I have created report on server mode. In my scenario the database name will keep changing as it moves through different phases of development. I am accessing report through report viewer control in server mode.Now i want to change the database name (connection string of shared data source) programmaticallyIs it possible?Thanks in advance
August 26th, 2009 10:25am

Hi Mitesh, If I have understood correctly, you want to change the connection string of a Shared Data Source programmatically in custom application. Microsoft SQL Server 2005 Reporting Services (SSRS) Web service has the method and property to manage the Report Server. In this case, we can use the GetDataSourceContents method to get the contents of the Data Source and then use the SetDataSourceContents to reset the contents of the Data Source. A sample code for setting the contents of a Data Source: using System; using System.Web.Services.Protocols; class Sample { public static void Main() { ReportingService2005 rs = new ReportingService2005(); rs.Credentials = System.Net.CredentialCache.DefaultCredentials; DataSourceDefinition definition = new DataSourceDefinition(); definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated; definition.ConnectString = "data source=(local);initial catalog=AdventureWorks2000"; definition.Enabled = true; definition.EnabledSpecified = true; definition.Extension = "SQL"; definition.ImpersonateUser = false; definition.ImpersonateUserSpecified = true; definition.Prompt = null; definition.WindowsCredentials = false; try { rs.SetDataSourceContents( "/SampleReports/AdventureWorks", definition ); } catch (SoapException e) { Console.WriteLine(e.Detail.OuterXml); } } } For more information, please see: ReportingService2005.GetDataSourceContents Method: http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.getdatasourcecontents.aspx ReportingService2005.SetDataSourceContents Method: http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.setdatasourcecontents.aspx If you have any more questions, please feel free to ask. Thanks, Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
August 27th, 2009 10:49am

I would like to change the Database name for the SSRS which is designed using 2008 and from where i can get asmx. i would like to know the url for the webservice for adding referrence?
December 26th, 2010 6:00am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics