次の方法で共有


例外が発生しない警告および状況の処理

Reporting Services では、警告および特定のエラーに対して例外をスローしません。たとえば、CreateReport メソッドを使用して新しいレポートをレポート サーバーにパブリッシュしたときに警告が発生した場合、その警告は Warning オブジェクトの配列として返されます。それらの警告は、適切な処置を実行できるように処理および表示する必要があります。

Try
   warnings = rs.CreateReport(name, parentFolder, 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 ex As SoapException
   Console.WriteLine(ex.Detail("Message").InnerXml)
End Try
try
{
   warnings = rs.CreateReport(name, parentFolder, 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 ex)
{
   Console.WriteLine(ex.Detail["Message"].InnerXml);
}

もう 1 つのエラー処理方法は、特定のメソッドの戻り値を評価することです。たとえば、FindItems メソッドを使用して、レポート サーバー データベースの特定のアイテムを検索できます。検索条件に一致するアイテムが見つからない場合、CatalogItem オブジェクトの null 配列が返されます。その配列を評価し、null を調べて、アイテムが見つからなかった場合はユーザーに知らせる必要があります。

参照

関連項目

Reporting Services SoapException クラス
CatalogItem

その他の技術情報

Reporting Services における例外処理の概要

ヘルプおよび情報

SQL Server 2005 の参考資料の入手