Lenguaje

ReportingService2010.CreateDataSource Método

Definición

Crea una nueva fuente de datos en una base de datos de un servidor de informes o en una biblioteca de 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

Parámetros

DataSource
String

El nombre de la fuente de datos incluye el nombre del archivo y, en modo SharePoint, la extensión (.rsds).

Parent
String

La URL totalmente calificada para la carpeta padre que contendrá la fuente de datos.

Overwrite
Boolean

Una Boolean expresión que indique si una fuente de datos existente con el mismo nombre en la ubicación especificada debe ser sobrscribida.

Definition
DataSourceDefinition

Un DataSourceDefinition objeto que describe las propiedades de conexión de la fuente de datos.

Properties
Property[]

Un array de Property objetos que define los nombres de propiedades y los valores a establecer para la fuente de datos.

Devoluciones

Un CatalogItem objeto para la fuente de datos recién creada.

Atributos

Ejemplos

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  

Comentarios

La siguiente tabla muestra la información sobre cabeceras y permisos sobre esta operación.

Uso de la cabecera SOAP (En) TrustedUserHeaderValue

(Fuera) ServerInfoHeaderValue
Permisos requeridos en modo nativo Creando una nueva fuente de datos: CreateDatasource en Parent

Actualización de una fuente de datos existente: UpdateContent en DataSource

Actualización de propiedades de la fuente de datos: UpdateContent Y UpdateProperties en DataSource
Permisos requeridos en el modo SharePoint Creando una nueva fuente de datos: <xref:Microsoft.SharePoint.SPBasePermissions.AddListItems> en Parent

Actualización de una fuente de datos existente: <xref:Microsoft.SharePoint.SPBasePermissions.EditListItems> en DataSource

Si la extensión .rsds se excluye del nombre de la fuente de datos, se devolverá un rsFileExtensionRequired error. Si se da una extensión .odc, se devuelve un rsNotSupported error.

Si se producen errores, la fuente de datos no se crea.

La longitud del Parent parámetro no puede superar los 260 caracteres; de lo contrario, se lanza una excepción SOAP con el código de error rsItemLengthExceeded.

El Parent parámetro no puede ser nulo ni vacío ni contener los siguientes caracteres reservados: : ? ; @ & = + $ , \ * > < | . ". Puedes usar el carácter de barra hacia adelante (/) para separar elementos en el nombre completo de la carpeta, pero no puedes usarlo al final del nombre de la carpeta.

Se aplica a