共用方式為


OracleRowUpdatingEventArgs 類別

定義

提供 RowUpdating 事件的資料。

public ref class OracleRowUpdatingEventArgs sealed : System::Data::Common::RowUpdatingEventArgs
public sealed class OracleRowUpdatingEventArgs : System.Data.Common.RowUpdatingEventArgs
type OracleRowUpdatingEventArgs = class
    inherit RowUpdatingEventArgs
Public NotInheritable Class OracleRowUpdatingEventArgs
Inherits RowUpdatingEventArgs
繼承
OracleRowUpdatingEventArgs

範例

下列範例示範如何使用 RowUpdatingRowUpdated 事件。

事件會 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時,每個數據列都會更新兩個事件。 執行順序如下:

  1. 中的 DataRow 值會移至參數值。

  2. 便會引發 OnRowUpdating 事件。

  3. 命令會執行。

  4. 如果命令設定為 FirstReturnedRecord,則會將第一個傳回的結果放在 中 DataRow

  5. 如果有輸出參數,它們會放在 中 DataRow

  6. 便會引發 OnRowUpdated 事件。

  7. 呼叫 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)

適用於