ReportingService2010.SetDataSourceContents Method (String, DataSourceDefinition)


Sets the connection properties associated with a DataSource.

Namespace:   ReportService2010
Assembly:  ReportService2010 (in ReportService2010.dll)

<SoapHeaderAttribute("ServerInfoHeaderValue", Direction := SoapHeaderDirection.Out)>
	RequestNamespace := "",
	ResponseNamespace := "",
	Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)>
Public Sub SetDataSourceContents (
	DataSource As String,
	Definition As DataSourceDefinition


Type: System.String

The fully qualified URL for the data source including the file name and .rsds file name extension.

Type: ReportService2010.DataSourceDefinition

A DataSourceDefinition object that contains the definition for the data source.

The table below shows header and permissions information on this operation.

SOAP Header Usage

(In) TrustedUserHeaderValue

(Out) ServerInfoHeaderValue

Native Mode Required Permissions


SharePoint Mode Required Permissions


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 causes 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 that you supply for the Prompt property is not saved.

With subscriptions, you may have to store credentials in the report server database so that the subscriptions can run unattended.

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

This method does not support changing Office Data Connections or files that have the .odc file name extension. Doing so causes an rsNotSupported error. For data sources with extensions other than .rsds or .odc, an rsWrongType error is returned.

Imports System
Imports System.IO
Imports System.Text
Imports System.Web.Services
Imports System.Web.Services.Protocols

Class Sample

    Public Shared Sub Main()

        Dim rs As New ReportingService2010()
        rs.Url = "http://<Server Name>/_vti_bin/ReportServer/" + _
        rs.Credentials = _

        Dim definition As New DataSourceDefinition()
        definition.CredentialRetrieval = _
        definition.ConnectString = _
            "data source=(local);initial catalog=AdventureWorks"
        definition.Enabled = True
        definition.EnabledSpecified = True
        definition.Extension = "SQL"
        definition.ImpersonateUser = False
        definition.ImpersonateUserSpecified = True
        definition.Prompt = Nothing
        definition.WindowsCredentials = False

            rs.SetDataSourceContents("http://<Server Name>" + _
                "/Docs/Documents/Data Sources/AdventureWorks.rsds", _

        Catch e As SoapException
        End Try

    End Sub

End Class
Return to top