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 头部 | (在) BatchHeaderValue (出局) ServerInfoHeaderValue |
| 所需的权限 | 创建新报告:CreateReport关于ParentReadProperties报告的数据来源和ReadProperties数据集更新现有报告:在 AND 上(如果 Properties包含属性)、以及UpdateProperties对报告数据源UpdateProperties和 对报告数据集ReportUpdatePropertiesReportUpdateReportDefinition |
参数长度 Parent 不得超过260个字符;否则,会抛出带有错误代码 rsItemLengthExceed的SOAP异常。
Parent参数不能为空或空,也不能包含以下保留字符: : ? ; @ & = + $ , \ * > < | . "。 你可以用斜杠字符(/)分隔文件夹完整路径名称中的项目,但不能在文件夹名称末尾使用。
如果发生错误,报告不会被创建。
向报告服务器数据库添加报告会 ModifiedBy 修改父文件夹的属性 ModifiedDate 。