DataAdapter class(OleDb,Sql and Oracle) exposes three events that can be used as record and respond to the changes being made to the database.
These events are as follows: This event is raised before a DML (Insert,Update,Delete) operation is to take place on a particular row. The RowUpdating event can be used for to gain additional control on the update operation like retaining old values before the changes are being made,cancel a particular update based on certain business logic or schedule it to be done later as a batch process.
The snippet of code below shows how these events can be used. No exception handling code has been written for better understanding of code.
You can compile the code using the following command at the command prompt.
csc /r:System.data.dll DAEvents.cs
You can run the DAEvents.exe at the command prompt. Happy Coding !!!