OracleRowUpdatingEventArgs Clase

Definición

Proporciona datos para el evento 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
Herencia
OracleRowUpdatingEventArgs

Ejemplos

En el ejemplo siguiente se muestra cómo usar los RowUpdating eventos y RowUpdated .

El RowUpdating evento devuelve esta salida:

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

El RowUpdated evento devuelve esta salida:

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

Comentarios

El RowUpdating evento se genera antes de una Update fila.

Cuando se usa Update, hay dos eventos que se producen para cada fila de datos actualizada. El orden de ejecución es el siguiente:

  1. Los valores de DataRow se mueven a los valores de parámetro.

  2. Se genera el evento OnRowUpdating.

  3. El comando se ejecuta.

  4. Si el comando se establece FirstReturnedRecorden , el primer resultado devuelto se coloca en .DataRow

  5. Si hay parámetros de salida, se colocan en .DataRow

  6. Se genera el evento OnRowUpdated.

  7. Se llama a AcceptChanges.

Constructores

OracleRowUpdatingEventArgs(DataRow, IDbCommand, StatementType, DataTableMapping)

Inicializa una nueva instancia de la clase OracleRowUpdatingEventArgs.

Propiedades

BaseCommand

Obtiene o establece el objeto IDbCommand para una instancia de esta clase.

(Heredado de RowUpdatingEventArgs)
Command

Obtiene o establece la interfaz OracleCommand que se va a ejecutar al llevar a cabo Update(DataSet).

Errors

Obtiene todos los errores generados por el proveedor de datos de .NET al ejecutar la propiedad Command.

(Heredado de RowUpdatingEventArgs)
Row

Obtiene el objeto DataRow que se enviará al servidor como parte de una operación de inserción, actualización, o eliminación.

(Heredado de RowUpdatingEventArgs)
StatementType

Obtiene el tipo de instrucción SQL que se va a ejecutar.

(Heredado de RowUpdatingEventArgs)
Status

Obtiene o establece UpdateStatus de la propiedad Command.

(Heredado de RowUpdatingEventArgs)
TableMapping

Obtiene DataTableMapping que se va a enviar mediante Update(DataSet).

(Heredado de RowUpdatingEventArgs)

Métodos

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Se aplica a