OracleRowUpdatingEventArgs 类    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 RowUpdating 事件提供数据。
public ref class OracleRowUpdatingEventArgs sealed : System::Data::Common::RowUpdatingEventArgspublic sealed class OracleRowUpdatingEventArgs : System.Data.Common.RowUpdatingEventArgstype OracleRowUpdatingEventArgs = class
    inherit RowUpdatingEventArgsPublic NotInheritable Class OracleRowUpdatingEventArgs
Inherits RowUpdatingEventArgs- 继承
示例
以下示例演示如何同时使用 RowUpdating 和 RowUpdated 事件。
事件 RowUpdating 返回以下输出:
Event Arguments: (command=OracleCommand commandType=2 status=0)
事件 RowUpdated 返回以下输出:
Event Arguments: (command=OracleCommand commandType=2 recordsAffected=1 row=DataRow[37] status=0)
// handler for RowUpdating event
private static void OnRowUpdating(object sender, OracleRowUpdatingEventArgs e)
{
    PrintEventArgs(e);
}
//Handler for RowUpdated event.
private static void OnRowUpdated(object sender, OracleRowUpdatedEventArgs e)
{
    PrintEventArgs(e);
}
public static int Main(String[] args)
{
    const string CONNECTION_STRING = "Data Source=Oracle8i;Integrated Security=yes";
    const string SELECT_ALL = "SELECT * FROM Scott.Emp";
    //Create DataAdapter.
    OracleDataAdapter rAdapter    = new OracleDataAdapter(SELECT_ALL, CONNECTION_STRING);
    //Create and fill DataSet (Select only first 5 rows.).
    DataSet rDataSet = new DataSet();
    rAdapter.Fill(rDataSet, 0, 5, "Table");
    //Modify DataSet.
    DataTable rTable = rDataSet.Tables["Table"];
    rTable.Rows[0][1] = "DYZY";
    //Add handlers.
    rAdapter.RowUpdating += new OracleRowUpdatingEventHandler( OnRowUpdating );
    rAdapter.RowUpdated += new OracleRowUpdatedEventHandler( OnRowUpdated );
    //Update--this operation fires two events (RowUpdating and RowUpdated) for each changed row.
    rAdapter.Update(rDataSet, "Table");
    //Remove handlers.
    rAdapter.RowUpdating -= new OracleRowUpdatingEventHandler( OnRowUpdating );
    rAdapter.RowUpdated -= new OracleRowUpdatedEventHandler( OnRowUpdated );
    return 0;
}
private static void PrintEventArgs(OracleRowUpdatingEventArgs args)
{
    Console.WriteLine("OnRowUpdating");
    Console.WriteLine("  event args: ("+
        " command=" + args.Command +
        " commandType=" + args.StatementType +
        " status=" + args.Status + ")");
}
private static void PrintEventArgs(OracleRowUpdatedEventArgs args)
{
    Console.WriteLine("OnRowUpdated");
    Console.WriteLine("  event args: ("+
        " command=" + args.Command +
        " commandType=" + args.StatementType +
        " recordsAffected=" + args.RecordsAffected +
        " status=" + args.Status + ")");
}
'Handler for RowUpdating event.
Private Shared Sub OnRowUpdating(sender As Object, e As OracleRowUpdatingEventArgs)
    PrintEventArgs(e)
End Sub
'Handler for RowUpdated event.
Private Shared Sub OnRowUpdated(sender As Object, e As OracleRowUpdatedEventArgs)
    PrintEventArgs(e)
End Sub
'Entry point which delegates to C-style main Private Function.
Public Overloads Shared Sub Main()
    System.Environment.ExitCode = Main(System.Environment.GetCommandLineArgs())
End Sub
Overloads Public Shared Function Main(args() As String) As Integer
    Const CONNECTION_STRING As String = "Data Source=Oracle8i;Integrated Security=yes"
    Const SELECT_ALL As String = "SELECT * FROM Scott.Emp"
    
    'Create DataAdapter.
    Dim rAdapter As New OracleDataAdapter(SELECT_ALL, CONNECTION_STRING)
    
    'Create and fill DataSet (Select only first 5 rows.).
    Dim rDataSet As New DataSet()
    rAdapter.Fill(rDataSet, 0, 5, "Table")
    
    'Modify DataSet.
    Dim rTable As DataTable = rDataSet.Tables("Table")
    rTable.Rows(0)(1) = "DYZY"
    
    'Add handlers.
    AddHandler rAdapter.RowUpdating, AddressOf OnRowUpdating
    AddHandler rAdapter.RowUpdated, AddressOf OnRowUpdated
    
    'Update--this operation fires two events (RowUpdating and RowUpdated) for each changed row. 
    rAdapter.Update(rDataSet, "Table")
    
    'Remove handlers.
    RemoveHandler rAdapter.RowUpdating, AddressOf OnRowUpdating
    RemoveHandler rAdapter.RowUpdated, AddressOf OnRowUpdated
    Return 0
End Function 'Main
Overloads Private Shared Sub PrintEventArgs(args As OracleRowUpdatingEventArgs)
    Console.WriteLine("OnRowUpdating")
    Console.WriteLine("  event args: (" & _
                    " command=" & _
                    args.Command.CommandText & _
                    " commandType=" & _
                    args.StatementType & _
                    " status=" & _
                    args.Status & _
                    ")")
End Sub
Overloads Private Shared Sub PrintEventArgs(args As OracleRowUpdatedEventArgs)
    Console.WriteLine("OnRowUpdated")
    Console.WriteLine("  event args: (" & _
                    " command=" & _
                    args.Command.CommandText & _
                    " commandType=" & _
                    args.StatementType & _
                    " recordsAffected=" & _
                    args.RecordsAffected & _
                    " status=" & _
                    args.Status & _
                    ")")
End Sub
注解
事件 RowUpdating 在 到 行之前 Update 引发。
使用 Update时,更新的每个数据行都会发生两个事件。 执行顺序如下:
- 中的 DataRow 值将移动到参数值。 
- 引发 OnRowUpdating 事件。 
- 命令将执行。 
- 如果命令设置为 - FirstReturnedRecord,则返回的第一个结果将放置在 中 DataRow。
- 如果有输出参数,则它们放置在 中 DataRow。 
- 引发 OnRowUpdated 事件。 
- 调用 AcceptChanges。 
构造函数
| OracleRowUpdatingEventArgs(DataRow, IDbCommand, StatementType, DataTableMapping) | 初始化 OracleRowUpdatingEventArgs 类的新实例。 | 
属性
| BaseCommand | 获取或设置此类的实例的 IDbCommand 对象。(继承自 RowUpdatingEventArgs) | 
| Command | 获取或设置进行 OracleCommand 时执行的 Update(DataSet)。 | 
| Errors | 获取当 Command 执行时 .NET 数据提供程序生成的任何错误。(继承自 RowUpdatingEventArgs) | 
| Row | 获取要作为插入、更新或删除操作的一部分发送到服务器的 DataRow。(继承自 RowUpdatingEventArgs) | 
| StatementType | 获取要执行的 SQL 语句的类型。(继承自 RowUpdatingEventArgs) | 
| Status | 获取或设置 UpdateStatus 属性的 Command。(继承自 RowUpdatingEventArgs) | 
| TableMapping | 获取要通过 DataTableMapping 发送的 Update(DataSet)。(继承自 RowUpdatingEventArgs) | 
方法
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) |