Handling Warnings and Cases that Do Not Cause Exceptions

Reporting Services does not throw exceptions for warnings and certain errors. For example, when you use the CreateReport method to publish a new report to a report server, any warnings that occur are returned as an array of Warning objects. These warnings should be handled and displayed so that appropriate action can be taken.

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);
}

Another way to handle errors is to evaluate the return values of certain methods. For example, the FindItems method can be used to search for specific items in the report server database. If no items are found that match the search criteria, a null array of CatalogItem objects is returned. You should evaluate the array, check for null, and let the user know if no items were found.

참고 항목

참조

Reporting Services SoapException Class
CatalogItem

관련 자료

Introducing Exception Handling in Reporting Services

도움말 및 정보

SQL Server 2005 지원 받기