Share via


ReportingService2010.CreateDataSource Metodo

Definizione

Crea una nuova origine dati in un database del server di report o in una raccolta di SharePoint.

public:
 ReportService2010::CatalogItem ^ CreateDataSource(System::String ^ DataSource, System::String ^ Parent, bool Overwrite, ReportService2010::DataSourceDefinition ^ Definition, cli::array <ReportService2010::Property ^> ^ Properties);
[System.Web.Services.Protocols.SoapDocumentMethod("http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer/CreateDataSource", 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("TrustedUserHeaderValue")]
[System.Web.Services.Protocols.SoapHeader("ServerInfoHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)]
public ReportService2010.CatalogItem CreateDataSource (string DataSource, string Parent, bool Overwrite, ReportService2010.DataSourceDefinition Definition, ReportService2010.Property[] Properties);
[<System.Web.Services.Protocols.SoapDocumentMethod("http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer/CreateDataSource", 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("TrustedUserHeaderValue")>]
[<System.Web.Services.Protocols.SoapHeader("ServerInfoHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)>]
member this.CreateDataSource : string * string * bool * ReportService2010.DataSourceDefinition * ReportService2010.Property[] -> ReportService2010.CatalogItem
Public Function CreateDataSource (DataSource As String, Parent As String, Overwrite As Boolean, Definition As DataSourceDefinition, Properties As Property()) As CatalogItem

Parametri

DataSource
String

Il nome dell'origine dati, inclusi il nome file e, in modalità SharePoint, l'estensione rsds.

Parent
String

L'URL completo della cartella padre che conterrà l'origine dati.

Overwrite
Boolean

Espressione Boolean che indica se è necessario sovrascrivere un'origine dati esistente con lo stesso nome nel percorso specificato.

Definition
DataSourceDefinition

Oggetto DataSourceDefinition che descrive le proprietà di connessione dell'origine dati.

Properties
Property[]

Matrice di oggetti Property che definisce i nomi e i valori delle proprietà da impostare per l'origine dati.

Restituisce

Oggetto CatalogItem per l'origine dati appena creata.

Attributi

Esempio

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;  

        string name = "AdventureWorks.rsds";  
        string parent = "http://<Server Name>/Docs/Documents/";  

        // 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());  
        }  
    }  
}  
Imports System  
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 name As String = "AdventureWorks.rsds"  
        Dim parent As String = "http://<Server Name>/Docs/Documents/"  

        ' 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  

End Class  

Commenti

Nella tabella seguente vengono mostrate le informazioni sull'intestazione e sulle autorizzazioni relative a questa operazione.

Utilizzo intestazione SOAP (In) TrustedUserHeaderValue

(Out) ServerInfoHeaderValue
Autorizzazioni necessarie per la modalità nativa Creazione di una nuova origine dati: CreateDatasource in Parent

Aggiornamento di un'origine dati esistente: UpdateContent in DataSource

Aggiornamento delle proprietà dell'origine dati: UpdateContent AND UpdateProperties in DataSource
Autorizzazioni necessarie per la modalità SharePoint Creazione di una nuova origine dati: <xref:Microsoft.SharePoint.SPBasePermissions.AddListItems> in Parent

Aggiornamento di un'origine dati esistente: <xref:Microsoft.SharePoint.SPBasePermissions.EditListItems> in DataSource

Se l'estensione rsds viene esclusa dal nome dell'origine dati, verrà restituito un rsFileExtensionRequired errore. Se viene specificata un'estensione odc, viene restituito un rsNotSupported errore.

Se si verificano errori, l'origine dati non viene creata.

La lunghezza del Parent parametro non può superare i 260 caratteri. In caso contrario, viene generata un'eccezione SOAP con il codice di errore rsItemLengthExceeded.

Il Parent parametro non può essere null o vuoto o contenere i caratteri riservati seguenti: : ? ; @ & = + $ , \ * > < | . ". È possibile utilizzare il carattere barra (/) per separare gli elementi nel nome completo del percorso della cartella, ma non è possibile usarlo alla fine del nome della cartella.

Si applica a