VersionNotFoundException 类
表示在尝试返回已经删除的 DataRow 版本时引发的异常。
**命名空间:**System.Data
**程序集:**System.Data(在 system.data.dll 中)
语法
声明
<SerializableAttribute> _
Public Class VersionNotFoundException
Inherits DataException
用法
Dim instance As VersionNotFoundException
[SerializableAttribute]
public class VersionNotFoundException : DataException
[SerializableAttribute]
public ref class VersionNotFoundException : public DataException
/** @attribute SerializableAttribute() */
public class VersionNotFoundException extends DataException
SerializableAttribute
public class VersionNotFoundException extends DataException
示例
下面的示例用一个 DataColumn 和十个 DataRow 对象创建 DataTable。在删除 DataRow 之后,若尝试返回已移除的行的当前版本,将导致引发 VersionNotFoundException 异常。
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
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.");
}
}
继承层次结构
System.Object
System.Exception
System.SystemException
System.Data.DataException
System.Data.VersionNotFoundException
线程安全
此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0