OracleRowUpdatedEventArgs Classe

Definizione

Fornisce dati per l'evento RowUpdated. La classe non può essere ereditata.

public ref class OracleRowUpdatedEventArgs sealed : System::Data::Common::RowUpdatedEventArgs
public sealed class OracleRowUpdatedEventArgs : System.Data.Common.RowUpdatedEventArgs
type OracleRowUpdatedEventArgs = class
    inherit RowUpdatedEventArgs
Public NotInheritable Class OracleRowUpdatedEventArgs
Inherits RowUpdatedEventArgs
Ereditarietà
OracleRowUpdatedEventArgs

Esempio

Nell'esempio seguente viene illustrato come usare sia gli RowUpdating eventi che RowUpdated gli eventi.

L'evento RowUpdating restituisce questo output:

Event Arguments: (command=OracleCommand commandType=2status=0)

L'evento RowUpdated restituisce questo output:

Event Arguments: (command= OracleCommend commandType=2 recordsAffected=1 row=System.Data.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);
    OracleCommandBuilder cb = new OracleCommandBuilder(rAdapter);

    //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)
        Dim cb As New OracleCommandBuilder(rAdapter)
        
        '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
End Class

Commenti

L'evento RowUpdated viene generato al Update termine di una riga.

Quando si usa Update, sono presenti due eventi che si verificano per ogni riga di dati aggiornata. L'ordine di esecuzione è il seguente:

  1. I valori nell'oggetto DataRow vengono spostati nei valori dei parametri.

  2. Viene generato l'evento OnRowUpdating.

  3. Il comando viene eseguito.

  4. Se il comando è impostato su FirstReturnedRecord, il primo risultato restituito viene inserito in DataRow.

  5. Se sono presenti parametri di output, vengono inseriti in DataRow.

  6. Viene generato l'evento OnRowUpdated.

  7. Chiamata del metodo AcceptChanges.

Costruttori

OracleRowUpdatedEventArgs(DataRow, IDbCommand, StatementType, DataTableMapping)

Inizializza una nuova istanza della classe OracleRowUpdatedEventArgs.

Proprietà

Command

Ottiene o imposta la classe OracleCommand eseguita quando viene chiamato il metodo Update(DataSet).

Errors

Ottiene tutti gli errori generati dal provider di dati .NET al momento dell'esecuzione del metodo Command.

(Ereditato da RowUpdatedEventArgs)
RecordsAffected

Ottiene il numero di righe modificate, inserite o eliminate dall'esecuzione dell'istruzione SQL.

(Ereditato da RowUpdatedEventArgs)
Row

Ottiene la classe DataRow inviata attraverso un metodo Update(DataSet).

(Ereditato da RowUpdatedEventArgs)
RowCount

Ottiene il numero di righe elaborate in un batch di record aggiornati.

(Ereditato da RowUpdatedEventArgs)
StatementType

Ottiene il tipo di istruzione SQL eseguita.

(Ereditato da RowUpdatedEventArgs)
Status

Ottiene l'oggetto UpdateStatus della proprietà Command.

(Ereditato da RowUpdatedEventArgs)
TableMapping

Ottiene la classe DataTableMapping inviata attraverso un metodo Update(DataSet).

(Ereditato da RowUpdatedEventArgs)

Metodi

CopyToRows(DataRow[])

Copia i riferimenti alle righe modificate nella matrice fornita.

(Ereditato da RowUpdatedEventArgs)
CopyToRows(DataRow[], Int32)

Copia i riferimenti alle righe modificate nella matrice fornita.

(Ereditato da RowUpdatedEventArgs)
Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Si applica a