ReportingService2005.CreateReport(String, String, Boolean, Byte[], Property[]) Metodo

Definizione

Aggiunge un nuovo report al database del server di report.

public:
 cli::array <ReportService2005::Warning ^> ^ CreateReport(System::String ^ Report, System::String ^ Parent, bool Overwrite, cli::array <System::Byte> ^ Definition, cli::array <ReportService2005::Property ^> ^ Properties);
public ReportService2005.Warning[] CreateReport (string Report, string Parent, bool Overwrite, byte[] Definition, ReportService2005.Property[] Properties);
member this.CreateReport : string * string * bool * byte[] * ReportService2005.Property[] -> ReportService2005.Warning[]
Public Function CreateReport (Report As String, Parent As String, Overwrite As Boolean, Definition As Byte(), Properties As Property()) As Warning()

Parametri

Report
String

Nome del nuovo rapporto.

Parent
String

URL completo della cartella padre nella quale aggiungere il report.

Overwrite
Boolean

Un'espressione Boolean che indica se è necessario sovrascrivere un report esistente con lo stesso nome nel percorso specificato.

Definition
Byte[]

Definizione del report da pubblicare sul server di report che corrisponde al contenuto di un file con estensione rdl. I dati XML sono definiti dal http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition/ Report Definition Language.

Properties
Property[]

Matrice di oggetti Property che contengono i nomi e i valori delle proprietà da impostare per il report.

Restituisce

Warning[]

Matrice di oggetti Warning che descrive gli avvisi generati durante la convalida della definizione del report.

Esempio

Per compilare questo esempio di codice, è necessario fare riferimento al Reporting Services WSDL e importare determinati spazi dei nomi. Per ulteriori informazioni, vedere compilazione ed esecuzione di esempi di codice. Nell'esempio di codice seguente viene pubblicato un report sotto forma di file di Report Definition Language (RDL) in un database del server di report.

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

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

      Dim definition As [Byte]() = Nothing  
      Dim warnings As Warning() = Nothing  
      Dim name As String = "MyReport"  

      Try  
         Dim stream As FileStream = File.OpenRead("MyReport.rdl")  
         definition = New [Byte](stream.Length - 1) {}  
         stream.Read(definition, 0, CInt(stream.Length - 1))  
         stream.Close()  

      Catch e As IOException  
         Console.WriteLine(e.Message)  
      End Try  

      Try  
         warnings = rs.CreateReport(name, "/Samples", False, definition, Nothing)  

         If Not (warnings Is Nothing) Then  
            Dim warning As Warning  
            For Each warning In  warnings  
               Console.WriteLine(warning.Message)  
            Next warning  

         Else  
            Console.WriteLine("Report: {0} created successfully with no warnings", name)  
         End If  

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

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

      Byte[] definition = null;  
      Warning[] warnings = null;  
      string name = "MyReport";  

      try  
      {  
         FileStream stream = File.OpenRead("MyReport.rdl");  
         definition = new Byte[stream.Length];  
         stream.Read(definition, 0, (int) stream.Length);  
         stream.Close();  
      }  

      catch(IOException e)  
      {  
         Console.WriteLine(e.Message);  
      }  

      try  
      {  
         warnings = rs.CreateReport(name, "/Samples", false, definition, null);  

         if (warnings != null)  
         {  
            foreach (Warning warning in warnings)  
            {  
               Console.WriteLine(warning.Message);  
            }  
         }  

         else  
            Console.WriteLine("Report: {0} created successfully with no warnings", name);  
      }  

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

   }  
}  

Commenti

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

Intestazioni SOAP (In) BatchHeaderValue

(Out) ServerInfoHeaderValue
Autorizzazioni necessarie Creazione di un nuovo report: CreateReport in Parent e ReadProperties nelle origini dati del report e ReadProperties nei set di dati del report

Aggiornamento di un report esistente: UpdateReportDefinition on Report e UpdateProperties on Report (se Properties contiene proprietà) e UpdateProperties nelle origini dati del report e UpdateProperties nei set di dati del report

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 percorso completo della cartella, ma non è possibile utilizzarlo alla fine del nome della cartella.

Se si verificano errori, il report non viene creato.

L'aggiunta di un report al database del server di report modifica le ModifiedBy ModifiedDate proprietà e della cartella padre.

Si applica a