Condividi tramite


Handling SMO Exceptions

Data aggiornamento: 14 aprile 2006

In managed code, exceptions are thrown when an error occurs. SMO methods and properties do not report success or failure in the return value. Instead, exceptions can be caught and handled by an exception handler.

Different exception classes exist in the SMO. Information about the exception can be extracted from the exception properties such as the Message property that gives a text message about the exception.

The exception handling statements are specific to the programming language. For example, in Microsoft Visual Basic it is the Catch statement.

Inner Exceptions

Exceptions can either be general or specific. General exceptions contain a set of specific exceptions. Several Catch statements can be used to handle anticipated errors and let remaining errors fall through to general exception handling code. Exceptions often occur in a cascading sequence. Frequently, an SMO exception might have been caused by an SQL exception. The way to detect this is to use the InnerException property successively to determine the original exception that caused the final, top-level exception.

[!NOTA] The SQLException exception is declared in the System.Data.SqlClient namespace.

Diagramma che illustra i livelli da cui viene generata un'eccezione

The diagram shows the flow of exceptions through the layers of the application.

Vedere anche

Attività

How to: Catch an Exception in Visual Basic .NET

Guida in linea e informazioni

Assistenza su SQL Server 2005