다음을 통해 공유


Handling SMO Exceptions

업데이트: 2006년 4월 14일

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.

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

예외 수준을 보여 주는 다이어그램

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

참고 항목

작업

How to: Catch an Exception in Visual Basic .NET

도움말 및 정보

SQL Server 2005 지원 받기