OracleRowUpdatingEventArgs Classe
Definição
Fornece dados para o evento de RowUpdating .Provides data for the RowUpdating event.
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
- Herança
Exemplos
O exemplo a seguir mostra como usar os RowUpdating eventos e RowUpdated .The following example shows how to use both the RowUpdating and RowUpdated events.
O RowUpdating evento retorna esta saída:The RowUpdating event returns this output:
Event Arguments: (command=OracleCommand commandType=2 status=0)
O RowUpdated evento retorna esta saída:The RowUpdated event returns this output:
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
Comentários
O RowUpdating evento é gerado antes de um Update para uma linha.The RowUpdating event is raised before an Update to a row.
Ao usar o Update , há dois eventos que ocorrem para cada linha de dados atualizada.When using Update, there are two events that occur for each data row updated. A ordem de execução é a seguinte:The order of execution is as follows:
Os valores no DataRow são movidos para os valores de parâmetro.The values in the DataRow are moved to the parameter values.
O OnRowUpdating evento é gerado.The OnRowUpdating event is raised.
O comando é executado.The command executes.
Se o comando for definido como
FirstReturnedRecord, o primeiro resultado retornado será colocado no DataRow .If the command is set toFirstReturnedRecord, the first returned result is placed in the DataRow.Se houver parâmetros de saída, eles serão colocados no DataRow .If there are output parameters, they are placed in the DataRow.
O OnRowUpdated evento é gerado.The OnRowUpdated event is raised.
AcceptChanges é chamado.AcceptChanges is called.
Construtores
| OracleRowUpdatingEventArgs(DataRow, IDbCommand, StatementType, DataTableMapping) |
Inicializa uma nova instância da classe OracleRowUpdatingEventArgs.Initializes a new instance of the OracleRowUpdatingEventArgs class. |
Propriedades
| BaseCommand |
Obtém ou define o objeto IDbCommand para uma instância desta classe.Gets or sets the IDbCommand object for an instance of this class. (Herdado de RowUpdatingEventArgs) |
| Command |
Obtém ou define o OracleCommand a ser executado ao realizar a Update(DataSet).Gets or sets the OracleCommand to execute when performing the Update(DataSet). |
| Errors |
Obtém erros gerados pelo provedor de dados .NET quando o Command é executado.Gets any errors generated by the .NET data provider when the Command executes. (Herdado de RowUpdatingEventArgs) |
| Row |
Obtém o DataRow que será enviado ao servidor como parte de uma operação de inserção, atualização ou exclusão.Gets the DataRow that will be sent to the server as part of an insert, update, or delete operation. (Herdado de RowUpdatingEventArgs) |
| StatementType |
Obtém o tipo de instrução SQL a ser executado.Gets the type of SQL statement to execute. (Herdado de RowUpdatingEventArgs) |
| Status |
Obtém ou define o UpdateStatus da propriedade Command.Gets or sets the UpdateStatus of the Command property. (Herdado de RowUpdatingEventArgs) |
| TableMapping |
Obtém o DataTableMapping a ser enviado por meio de Update(DataSet).Gets the DataTableMapping to send through the Update(DataSet). (Herdado de RowUpdatingEventArgs) |
Métodos
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |