ReportingService2010.SetDataSourceContents 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置与 DataSource 关联的连接属性。
public:
void SetDataSourceContents(System::String ^ DataSource, ReportService2010::DataSourceDefinition ^ Definition);
[System.Web.Services.Protocols.SoapDocumentMethod("http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer/SetDataSourceContents", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, RequestNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", ResponseNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", Use=System.Web.Services.Description.SoapBindingUse.Literal)]
[System.Web.Services.Protocols.SoapHeader("ServerInfoHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)]
[System.Web.Services.Protocols.SoapHeader("TrustedUserHeaderValue")]
public void SetDataSourceContents (string DataSource, ReportService2010.DataSourceDefinition Definition);
[<System.Web.Services.Protocols.SoapDocumentMethod("http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer/SetDataSourceContents", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, RequestNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", ResponseNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", Use=System.Web.Services.Description.SoapBindingUse.Literal)>]
[<System.Web.Services.Protocols.SoapHeader("ServerInfoHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)>]
[<System.Web.Services.Protocols.SoapHeader("TrustedUserHeaderValue")>]
member this.SetDataSourceContents : string * ReportService2010.DataSourceDefinition -> unit
Public Sub SetDataSourceContents (DataSource As String, Definition As DataSourceDefinition)
参数
- DataSource
- String
数据源的完全限定 URL,其中包括文件名和 .rsds 文件扩展名。
- Definition
- DataSourceDefinition
一个包含数据源的定义的 DataSourceDefinition 对象。
- 属性
示例
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
class Sample
{
static void Main(string[] args)
{
ReportingService2010 rs = new ReportingService2010();
rs.Url = "http://<Server Name>/_vti_bin/ReportServer/" +
"ReportService2010.asmx";
rs.Credentials =
System.Net.CredentialCache.DefaultCredentials;
DataSourceDefinition definition =
new DataSourceDefinition();
definition.CredentialRetrieval =
CredentialRetrievalEnum.Integrated;
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 = null;
definition.WindowsCredentials = true;
try
{
rs.SetDataSourceContents("http://<Server Name>" +
"/Docs/Documents/Data Sources/AdventureWorks.rsds",
definition);
}
catch (SoapException e)
{
Console.WriteLine(e.Detail.OuterXml);
}
}
}
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/" + _
"ReportService2010.asmx"
rs.Credentials = _
System.Net.CredentialCache.DefaultCredentials
Dim definition As New DataSourceDefinition()
definition.CredentialRetrieval = _
CredentialRetrievalEnum.Integrated
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
Try
rs.SetDataSourceContents("http://<Server Name>" + _
"/Docs/Documents/Data Sources/AdventureWorks.rsds", _
definition)
Catch e As SoapException
Console.WriteLine(e.Detail.OuterXml)
End Try
End Sub
End Class
注解
下表显示了有关此操作的标头和权限信息。
SOAP 标头用法 | (In) TrustedUserHeaderValue (Out) ServerInfoHeaderValue |
本机模式所需的权限 | UpdateContent |
SharePoint 模式所需权限 | <xref:Microsoft.SharePoint.SPBasePermissions.EditListItems> |
若要删除属于数据源定义的属性,请在 Visual Basic) 中将这些属性的值设置为 null
(Nothing
。
如果将数据源定义的 属性设置为 CredentialRetrievalIntegrated
或 Prompt
,请不要为 UserName 或 Password提供值。 这样做会导致 SOAP 异常, rsInvalidElementCombination
错误代码为 。
如果将数据源定义的 属性设置为 CredentialRetrievalIntegrated
或 Store
,则不会保存为 Prompt 属性提供的任何值。
使用订阅时,可能需要将凭据存储在报表服务器数据库中,以便订阅可以无人参与地运行。
将 ConnectString 数据源定义的 属性设置为 null
在 Visual Basic) 中 (Nothing
会导致 SOAP 异常,错误代码 rsInvalidXML
为 。 如果不想为 ConnectString提供值,请将其值设置为空字符串 (“”) 。
此方法不支持更改 Office 数据连接或文件扩展名为 .odc 的文件。 这样做会导致错误 rsNotSupported
。 对于具有除 .rsds 或 .odc 以外的扩展的数据源,将返回错误 rsWrongType
。