語言

ReportingService2005.CreateDataSource 方法

定義

在報告伺服器資料庫中建立新的資料來源。

public:
 void CreateDataSource(System::String ^ DataSource, System::String ^ Parent, bool Overwrite, ReportService2005::DataSourceDefinition ^ Definition, cli::array <ReportService2005::Property ^> ^ Properties);
public void CreateDataSource(string DataSource, string Parent, bool Overwrite, ReportService2005.DataSourceDefinition Definition, ReportService2005.Property[] Properties);
member this.CreateDataSource : string * string * bool * ReportService2005.DataSourceDefinition * ReportService2005.Property[] -> unit
Public Sub CreateDataSource (DataSource As String, Parent As String, Overwrite As Boolean, Definition As DataSourceDefinition, Properties As Property())

參數

DataSource
String

資料來源的名稱。

Parent
String

包含資料來源的父資料夾的完整路徑名稱。

Overwrite
Boolean

一個 Boolean 表示在指定地點中名稱相同且現有資料來源是否應覆寫的表達式。

Definition
DataSourceDefinition

一個 DataSourceDefinition 描述資料來源連接屬性的物件。

Properties
Property[]

一個物件陣列 Property ,定義資料來源要設定的屬性名稱和值。

範例

要編譯此程式碼範例,您必須參考 Reporting Services WSDL 並匯入特定命名空間。 欲了解更多資訊,請參閱編 譯與執行程式碼範例。 以下程式碼範例在報告伺服器資料庫的根資料夾中建立一個新的資料來源:

Imports System  
Imports System.Web.Services.Protocols  

Class Sample  
   Public Shared Sub Main()  
      Dim rs As New ReportingService2005()  
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials  

      Dim name As String = "AdventureWorks"  
      Dim parent As String = "/"  

      ' Define the data source definition.  
      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.ImpersonateUserSpecified = False  
      'Use the default prompt string.  
      definition.Prompt = Nothing  
      definition.WindowsCredentials = False  

      Try  
         rs.CreateDataSource(name, parent, False, definition, Nothing)  

      Catch e As SoapException  
         Console.WriteLine(e.Detail.InnerXml.ToString())  
      End Try  
   End Sub 'Main  
End Class 'Sample  
using System;  
using System.Web.Services.Protocols;  

class Sample  
{  
   public static void Main()  
   {  
      ReportingService2005 rs = new ReportingService2005();  
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials;  

      string name = "AdventureWorks";  
      string parent ="/";  

      // Define the data source definition.  
      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.ImpersonateUserSpecified = false;  
      //Use the default prompt string.  
      definition.Prompt = null;  
      definition.WindowsCredentials = false;  

      try  
      {  
         rs.CreateDataSource(name, parent, false, definition, null);  
      }  

      catch (SoapException e)  
      {  
         Console.WriteLine(e.Detail.InnerXml.ToString());   
      }  
   }  
}  

備註

下表顯示此操作的標頭與權限資訊。

SOAP 標頭 (在) BatchHeaderValue

(出局) ServerInfoHeaderValue
必要權限 建立新資料來源: CreateDatasource on Parent

更新現有資料來源: UpdateContent 關於 DataSource

更新資料來源屬性: UpdateContent AND UpdateProperties on DataSource

若發生錯誤,則不會建立該資料來源。

參數長度 Parent 不得超過 260 個字元;否則會拋出帶有錯誤碼 rsItemLengthExceed 的 SOAP 例外。

Parent參數不能為空或空,或包含以下保留字元: : ? ; @ & = + $ , \ * > < | . "。 你可以用斜杠(/)來分隔資料夾完整路徑名稱中的項目,但不能用在資料夾名稱的末尾

適用於