Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

OracleRowUpdatingEventArgs Class

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Provides data for the RowUpdating event. This class cannot be inherited.

For a list of all members of this type, see OracleRowUpdatingEventArgs Members.

System.Object
   System.EventArgs
      System.Data.Common.RowUpdatingEventArgs
         System.Data.OracleClient.OracleRowUpdatingEventArgs

[Visual Basic]
NotInheritable Public Class OracleRowUpdatingEventArgs
   Inherits RowUpdatingEventArgs
[C#]
public sealed class OracleRowUpdatingEventArgs :
   RowUpdatingEventArgs
[C++]
public __gc __sealed class OracleRowUpdatingEventArgs : public
   RowUpdatingEventArgs
[JScript]
public class OracleRowUpdatingEventArgs extends
   RowUpdatingEventArgs

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

The RowUpdating event is raised before an Update to a row.

When using Update, there are two events that occur for each data row updated. The order of execution is as follows:

  1. The values in the DataRow are moved to the parameter values.
  2. The OnRowUpdating event is raised.
  3. The command executes.
  4. If the command is set to FirstReturnedRecord, then the first returned result is placed in the DataRow.
  5. If there are output parameters, they are placed in the DataRow.
  6. The OnRowUpdated event is raised.
  7. AcceptChanges is called.

Example

[Visual Basic, C#, C++] The following example shows how to use both the RowUpdating and RowUpdated events.

[Visual Basic, C#, C++] The RowUpdating event returns this output:

[Visual Basic, C#, C++] event args: (command=System.Data.OracleClient.OracleCommand commandType=2 status=0)

[Visual Basic, C#, C++] The RowUpdated event returns this output:

[Visual Basic, C#, C++] event args: (command=System.Data.OracleClient.OracleCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0)

[Visual Basic] 
'Handler for RowUpdating event.
Protected Shared Sub OnRowUpdating(sender As Object, e As OracleRowUpdatingEventArgs)
    PrintEventArgs(e)
End Sub 'OnRowUpdating

'Handler for RowUpdated event.
Protected Shared Sub OnRowUpdated(sender As Object, e As OracleRowUpdatedEventArgs)
    PrintEventArgs(e)
End Sub 'OnRowUpdated

'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 Products"
    
    '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) = "new product"
    
    '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 Protected 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 'PrintEventArgs


Overloads Protected 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 'PrintEventArgs

[C#] 
// handler for RowUpdating event
 protected static void OnRowUpdating(object sender, OracleRowUpdatingEventArgs e) {
    PrintEventArgs(e);
 }
 
 //Handler for RowUpdated event.
 protected 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 Products";
 
    //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] = "new product";
 
    //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;
 }
 
 protected static void PrintEventArgs(OracleRowUpdatingEventArgs args) {
    Console.WriteLine("OnRowUpdating");
    Console.WriteLine("  event args: ("+
           " command=" + args.Command + 
           " commandType=" + args.StatementType + 
           " status=" + args.Status + ")");
 }
 
 protected static void PrintEventArgs(OracleRowUpdatedEventArgs args) {
    Console.WriteLine("OnRowUpdated");
    Console.WriteLine("  event args: ("+
           " command=" + args.Command +
           " commandType=" + args.StatementType + 
           " recordsAffected=" + args.RecordsAffected + 
           " status=" + args.Status + ")");
 }

[C++] 
// handler for RowUpdating event
protected:
 static void OnRowUpdating(Object* /*sender*/, OracleRowUpdatingEventArgs* e) {
    PrintEventArgs(e);
 }
 
 //Handler for RowUpdated event.
 static void OnRowUpdated(Object* /*sender*/, OracleRowUpdatedEventArgs* e) {
    PrintEventArgs(e);
 }
 
public:
 static int main() {
    String* CONNECTION_STRING = S"Data Source=Oracle8i;Integrated Security=yes";
    String* SELECT_ALL = S"select * from Products";
 
    //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, S"Table");
 
    //Modify DataSet.
    DataTable* rTable = rDataSet->Tables->Item[S"Table"];
    rTable->Rows->Item[0]->Item[1] = S"new product";
 
    //Add handlers.
    rAdapter->RowUpdating += new OracleRowUpdatingEventHandler(0, OnRowUpdating );
    rAdapter->RowUpdated += new OracleRowUpdatedEventHandler(0, OnRowUpdated );
 
    //Update--this operation fires two events (RowUpdating and RowUpdated) for each changed row. 
    rAdapter->Update(rDataSet, S"Table");
 
    //Remove handlers.
    rAdapter->RowUpdating -= new OracleRowUpdatingEventHandler(0, OnRowUpdating );
    rAdapter->RowUpdated -= new OracleRowUpdatedEventHandler(0, OnRowUpdated );
    return 0;
 }
 
protected:
 static void PrintEventArgs(OracleRowUpdatingEventArgs* args) {
    Console::WriteLine(S"OnRowUpdating");
    Console::WriteLine(
       String::Format( S"  event args: ( command={0} commandType={1} status={2})",
          args->Command, __box(args->StatementType), __box(args->Status)));
 }
 
 static void PrintEventArgs(OracleRowUpdatedEventArgs* args) {
    Console::WriteLine(S"OnRowUpdated");
    Console::WriteLine(String::Concat(
       String::Format( S"  event args: ( command={0} commandType={1} ",
          args->Command, __box(args->StatementType)),
       String::Format( S"recordsAffected={2} status={3})",
          __box(args->RecordsAffected), __box(args->Status))));
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Data.OracleClient

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Data.Oracleclient (in System.Data.Oracleclient.dll)

See Also

OracleRowUpdatingEventArgs Members | System.Data.OracleClient Namespace

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.