DbException 類別

定義

代表資料來源擲回之所有例外狀況的基底類別。The base class for all exceptions thrown on behalf of the data source.

public ref class DbException abstract : Exception
public ref class DbException abstract : System::Runtime::InteropServices::ExternalException
public abstract class DbException : Exception
public abstract class DbException : System.Runtime.InteropServices.ExternalException
[System.Serializable]
public abstract class DbException : System.Runtime.InteropServices.ExternalException
type DbException = class
    inherit Exception
type DbException = class
    inherit ExternalException
[<System.Serializable>]
type DbException = class
    inherit ExternalException
Public MustInherit Class DbException
Inherits Exception
Public MustInherit Class DbException
Inherits ExternalException
繼承
DbException
繼承
衍生
屬性

備註

DbException類別是抽象類別,用來做為提供者特定例外狀況類別的基類。The DbException class is an abstract class used as the base class for provider-specific exception class implementations.

如需處理 .NET Framework 資料提供者之例外狀況的一般資訊,請參閱 SqlExceptionFor general information about handling exceptions for a .NET Framework data provider, see SqlException.

建構函式

DbException()

初始化 DbException 類別的新執行個體。Initializes a new instance of the DbException class.

DbException(SerializationInfo, StreamingContext)

使用指定的序列化資訊和內容,初始化 DbException 類別的新執行個體。Initializes a new instance of the DbException class with the specified serialization information and context.

DbException(String)

使用指定的錯誤訊息,初始化 DbException 類別的新執行個體。Initializes a new instance of the DbException class with the specified error message.

DbException(String, Exception)

初始化具有指定的錯誤訊息以及造成此例外狀況的內部例外狀況參考之 DbException 類別的新執行個體。Initializes a new instance of the DbException class with the specified error message and a reference to the inner exception that is the cause of this exception.

DbException(String, Int32)

使用指定的錯誤訊息和錯誤碼,初始化 DbException 類別的新執行個體。Initializes a new instance of the DbException class with the specified error message and error code.

屬性

Data

取得鍵值組的集合,這些鍵值組會提供關於例外狀況的其他使用者定義資訊。Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(繼承來源 Exception)
ErrorCode

取得錯誤的 HRESULTGets the HRESULT of the error.

(繼承來源 ExternalException)
HelpLink

取得或設定與這個例外狀況相關聯的說明檔連結。Gets or sets a link to the help file associated with this exception.

(繼承來源 Exception)
HResult

取得或設定 HRESULT,它是指派給特定例外狀況的編碼數值。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(繼承來源 Exception)
InnerException

取得造成目前例外狀況的 Exception 執行個體。Gets the Exception instance that caused the current exception.

(繼承來源 Exception)
IsTransient

指出此 DbException 所代表的錯誤是否可能是暫時性錯誤,亦即,重試觸發作業是否可能會成功,而不需要任何其他變更。Indicates whether the error represented by this DbException could be a transient error, i.e. if retrying the triggering operation may succeed without any other change.

Message

取得描述目前例外狀況的訊息。Gets a message that describes the current exception.

(繼承來源 Exception)
Source

取得或設定造成錯誤的應用程式或物件的名稱。Gets or sets the name of the application or the object that causes the error.

(繼承來源 Exception)
SqlState

針對支援的資料庫提供者,包含標準 SQL 5 字元傳回碼,指出資料庫作業成功或失敗。For database providers which support it, contains a standard SQL 5-character return code indicating the success or failure of the database operation. 前 2 個字元代表傳回碼的類別 (例如錯誤、成功),而最後 3 個字元代表子類別,允許以資料庫可移植的方式偵測錯誤案例。The first 2 characters represent the class of the return code (e.g. error, success), while the last 3 characters represent the subclass, allowing detection of error scenarios in a database-portable way.

針對不支援的資料庫提供者,或不適用的錯誤案例,包含 nullFor database providers which don't support it, or for inapplicable error scenarios, contains null.

StackTrace

取得呼叫堆疊上即時運算框架的字串表示。Gets a string representation of the immediate frames on the call stack.

(繼承來源 Exception)
TargetSite

取得擲回目前例外狀況的方法。Gets the method that throws the current exception.

(繼承來源 Exception)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetBaseException()

在衍生類別中覆寫時,傳回一或多個後續的例外狀況的根本原因 ExceptionWhen overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(繼承來源 Exception)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetObjectData(SerializationInfo, StreamingContext)

在衍生類別中覆寫時,使用例外狀況的資訊設定 SerializationInfoWhen overridden in a derived class, sets the SerializationInfo with information about the exception.

(繼承來源 Exception)
GetType()

取得目前執行個體的執行階段類型。Gets the runtime type of the current instance.

(繼承來源 Exception)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

建立並傳回目前例外狀況的字串表示。Creates and returns a string representation of the current exception.

(繼承來源 Exception)
ToString()

傳回字串,其中包含錯誤的 HRESULT。Returns a string that contains the HRESULT of the error.

(繼承來源 ExternalException)

事件

SerializeObjectState

當例外狀況序列化,以建立包含例外狀況相關序列化資料的例外狀況狀態物件時,就會發生此事件。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(繼承來源 Exception)

適用於