ReportingService2005.CreateReport 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将新的报表添加到报表服务器数据库。
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()
参数
- Report
- String
新报表的名称。
- Parent
- String
要向其中添加报表的父文件夹的完全限定 URL。
- Overwrite
- Boolean
一个 Boolean
表达式,指示是否应覆盖指定位置中具有相同名称的现有报表。
- Definition
- Byte[]
要发布到报表服务器的报表定义,即 .rdl 文件的内容。 XML 数据由 http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition/ 报表定义语言 定义。
返回
Warning 对象的数组,它描述在验证报表定义时出现的任何警告。
示例
若要编译此代码示例,必须引用 Reporting Services WSDL 并导入某些命名空间。 有关详细信息,请参阅 编译和运行代码示例。 下面的代码示例以报表定义语言 (RDL) 文件的形式将报表发布到报表服务器数据库。
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());
}
}
}
注解
下表显示了有关此操作的标头和权限信息。
SOAP 标头 | (In) BatchHeaderValue (Out) ServerInfoHeaderValue |
所需的权限 | 创建新报表: CreateReport 在 Parent 报表数据源上的 AND ReadProperties 上,在 ReadProperties 报表的数据集上更新现有报表: UpdateReportDefinition Report 在 (UpdateProperties 上Report ,如果Properties 包含报表数据源上的属性) AND UpdateProperties 和报表数据集上的 AND UpdateProperties |
参数的 Parent
长度不能超过 260 个字符;否则,将引发 SOAP 异常,错误代码 为 rsItemLengthExceededed。
参数 Parent
不能为 null 或空,也不能包含以下保留字符: : ? ; @ & = + $ , \ * > < | . "
。 可以使用 /) (正斜杠字符分隔文件夹的完整路径名称中的项目,但不能在文件夹名称的末尾使用它。
如果发生错误,则不会创建报表。
将报表添加到报表服务器数据库会 ModifiedBy 修改父文件夹的 和 ModifiedDate 属性。