Export (0) Print
Expand All
Expand Minimize

SetDataSourceContents Method

SQL Server 2000

ReportingService.SetDataSourceContents Method

Sets the contents of a data source.

Public Sub SetDataSourceContents(
   ByVal DataSource As String _
   ByVal Definition As [Namespace].DataSourceDefinition _
) As String
   Member of [Namespace].ReportingService

public void SetDataSourceContents(
   string DataSource,
   [Namespace].DataSourceDefinition Definition
   Member of [Namespace].ReportingService
The full path name of the data source.
A data source definition (DataSourceDefinition object) that contains the definition for the data source.

Operation Description
Update Content Required on the data source to add or modify its connection properties.


To remove properties that are part of the data source definition, set the values of those properties to null (Nothing in Visual Basic).

If you set the CredentialRetrieval property of the data source definition to Integrated or Prompt, do not supply values for UserName or Password. Doing so results in a SOAP exception with the error code rsInvalidElementCombination.

If you set the CredentialRetrieval property of the data source definition to Integrated or Store, any value you supply for the Prompt property is not saved.

With subscriptions, it may be necessary to store credentials in the report server database so that the subscriptions can run unattended.

Setting the ConnectionString property of the data source definition to null (Nothing in Visual Basic) results in a SOAP exception with the error code rsInvalidXML. If you do not want to supply a value for ConnectionString, set its value to an empty string ("").


To compile the following code example, you must reference the Reporting Services WSDL and import certain namespaces. For more information, see Compiling and Running Code Examples. The following example code uses the SetDataSourceContents method to set the data source definition for an existing data source named AdventureWorks:

Imports System
Imports System.Web.Services.Protocols

Class Sample
   Public Shared Sub Main()
      Dim rs As New RSWebService()
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials
      Dim definition As 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 = Nothing
      definition.WindowsCredentials = False
         rs.SetDataSourceContents("/SampleReports/AdventureWorks", definition)
      Catch e As SoapException
      End Try
   End Sub 'Main
End Class 'Sample

using System;
using System.Web.Services.Protocols;

class Sample
   public static void Main()
      RSWebService rs = new RSWebService();
      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;

         rs.SetDataSourceContents( "/SampleReports/AdventureWorks", definition );

      catch (SoapException e)
See Also

ReportingService Class

Reporting Services Web Service Library

© 2014 Microsoft