OracleException 類別

定義

例外狀況,當 Oracle 資料庫或 .NET Framework Data Provider for Oracle 傳回警告或錯誤時所產生。The exception that is generated when a warning or error is returned by an Oracle database or the .NET Framework Data Provider for Oracle. 此類別無法獲得繼承。This class cannot be inherited.

public ref class OracleException sealed : SystemException
public ref class OracleException sealed : System::Data::Common::DbException
[System.Serializable]
public sealed class OracleException : SystemException
[System.Serializable]
public sealed class OracleException : System.Data.Common.DbException
[<System.Serializable>]
type OracleException = class
    inherit SystemException
[<System.Serializable>]
type OracleException = class
    inherit DbException
Public NotInheritable Class OracleException
Inherits SystemException
Public NotInheritable Class OracleException
Inherits DbException
繼承
OracleException
繼承
屬性

範例

下列範例會產生 OracleException 資料庫遺失的原因,然後顯示例外狀況。The following example generates an OracleException due to a missing database, and then displays the exception.

public void ShowOracleException()
{
   OracleConnection myConnection =
      new OracleConnection("Data Source=Oracle8i;Integrated Security=yes");

   try
   {
      myConnection.Open();
   }
   catch (OracleException e)
   {
     string errorMessage = "Code: " + e.Code + "\n" +
                           "Message: " + e.Message;

     System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
     log.Source = "My Application";
     log.WriteEntry(errorMessage);
     Console.WriteLine("An exception occurred. Please contact your system administrator.");
   }
}
Public Sub ShowOracleException() 

   Dim myConnection As OracleConnection = _
      New OracleConnection("Data Source=Oracle8i;Integrated Security=yes")

   Try 

      myConnection.Open()

   Catch e As OracleException

     Dim errorMessage As String = "Code: " & e.Code & vbCrLf & _
                                  "Message: " & e.Message

     Dim log As New System.Diagnostics.EventLog()
     log.Source = "My Application"
     log.WriteEntry(errorMessage)
     Console.WriteLine("An exception occurred. Please contact your system administrator.")

   End Try
End Sub

備註

每當遇到無法處理的情況時,就會建立這個類別 OracleDataAdapterThis class is created whenever the OracleDataAdapter encounters a situation that it cannot handle.

如果發生嚴重錯誤,伺服器可能會關閉 OracleConnectionIf the severity of the error is too great, the server may close the OracleConnection. 但是,使用者可以再次開啟連線,然後繼續進行。However, the user can reopen the connection and continue.

屬性

Code

取得錯誤的程式碼部分,整數值。Gets the code portion of the error as an integer.

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.

(繼承來源 DbException)
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.

(繼承來源 DbException)
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)

使用例外狀況的相關資訊來設定 SerializationInfoSets the SerializationInfo with information about the 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)

適用於