VersionNotFoundException 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表當你嘗試回傳已被刪除的 a DataRow 版本時拋出的例外。
public ref class VersionNotFoundException : System::Data::DataException
[System.Serializable]
public class VersionNotFoundException : System.Data.DataException
public class VersionNotFoundException : System.Data.DataException
[<System.Serializable>]
type VersionNotFoundException = class
inherit DataException
type VersionNotFoundException = class
inherit DataException
Public Class VersionNotFoundException
Inherits DataException
- 繼承
- 屬性
範例
以下範例會產生 DataTable 一個包含1 DataColumn 和10 DataRow 個物件的 a。 刪除 後 DataRow,嘗試回傳被移除列的當前版本會觸發 VersionNotFoundException 異常。
private void DemonstrateVersionNotFoundException()
{
// Create a DataTable with one column.
DataTable table = new DataTable("NewTable");
DataColumn column = new DataColumn("NewColumn");
table.Columns.Add(column);
DataRow newRow;
for(int i = 0;i <10;i++)
{
newRow = table.NewRow();
newRow["NewColumn"] = i;
table.Rows.Add(newRow);
}
table.AcceptChanges();
try
{
Console.WriteLine("Trying...");
DataRow removedRow = table.Rows[9];
removedRow.Delete();
removedRow.AcceptChanges();
// Try to get the Current row version.
Console.WriteLine(removedRow[0,DataRowVersion.Current]);
}
catch(System.Data.VersionNotFoundException)
{
Console.WriteLine("Current version of row not found.");
}
}
Private Sub DemonstrateVersionNotFoundException()
' Create a DataTable with one column.
Dim table As New DataTable("NewTable")
Dim column As New DataColumn("NewColumn")
table.Columns.Add(column)
Dim newRow As DataRow
Dim i As Integer
For i = 0 To 9
newRow = table.NewRow()
newRow("NewColumn") = i
table.Rows.Add(newRow)
Next i
table.AcceptChanges()
Try
Console.WriteLine("Trying...")
Dim removedRow As DataRow = table.Rows(9)
removedRow.Delete()
removedRow.AcceptChanges()
' Try to get the Current row version.
Console.WriteLine(removedRow(0, DataRowVersion.Current))
Catch e As System.Data.VersionNotFoundException
Console.WriteLine("Current version of row not found.")
End Try
End Sub
建構函式
| 名稱 | Description |
|---|---|
| VersionNotFoundException() |
初始化 VersionNotFoundException 類別的新執行個體。 |
| VersionNotFoundException(SerializationInfo, StreamingContext) |
初始化一個新的類別實例 VersionNotFoundException ,並附有序列化資訊。 |
| VersionNotFoundException(String, Exception) |
初始化類別的新實例 VersionNotFoundException ,並附上指定的錯誤訊息及導致該異常的內部例外的參考。 |
| VersionNotFoundException(String) |
初始化一個包含指定字串的 VersionNotFoundException 類別實例。 |
屬性
| 名稱 | Description |
|---|---|
| Data |
取得索引鍵/值組的集合,提供例外狀況的其他使用者定義資訊。 (繼承來源 Exception) |
| HelpLink |
取得或設定與這個例外狀況相關聯的說明檔連結。 (繼承來源 Exception) |
| HResult |
取得或設定 HRESULT,這是指派給特定例外狀況的編碼數值。 (繼承來源 Exception) |
| InnerException |
會取得 Exception 造成目前例外的實例。 (繼承來源 Exception) |
| Message |
取得描述目前例外狀況的訊息。 (繼承來源 Exception) |
| Source |
取得或設定造成錯誤之應用程式或物件的名稱。 (繼承來源 Exception) |
| StackTrace |
取得呼叫堆疊上即時框架的字串表示。 (繼承來源 Exception) |
| TargetSite |
取得擲回目前例外狀況的方法。 (繼承來源 Exception) |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
判斷指定的 物件是否等於目前的物件。 (繼承來源 Object) |
| GetBaseException() |
當在派生類別中被覆寫時,回傳 Exception 是一個或多個後續例外的根因。 (繼承來源 Exception) |
| GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
| GetObjectData(SerializationInfo, StreamingContext) |
在衍生類別中覆寫時,使用例外狀況的相關信息來設定 SerializationInfo。 (繼承來源 Exception) |
| GetType() |
取得目前實例的運行時間類型。 (繼承來源 Exception) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
建立並傳回目前例外狀況的字串表示。 (繼承來源 Exception) |
事件
| 名稱 | Description |
|---|---|
| SerializeObjectState |
發生於例外狀況串行化以建立例外狀況狀態物件,其中包含例外狀況的串行化數據。 (繼承來源 Exception) |