MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology


ADO.NET Projects

ADO.NET Project 1

ADO.NET Examples


Handling DataAdapter Events
Previous Home Next

DataAdapter supports only two events:

OnRowUpdating and OnRowUpdated.

These two events occur on either side of the actual dataset update, providing fine control of the process.

  1. OnRowUpdating Event
  2. The OnRowUpdating event is raised after the Update method has set the parameter values of the command to be executed but before the command is executed.The event handler for this event receives an argument whose properties provide essential information about the command that is about to be executed.

    The class of the event arguments is defined by the Data Provider, so it will be either OleDbRowUpdatingEventArgs or SqlRowUpdatingEventArgs if one of the .NET Framework Data Providers is used.

    RowUpdatingEventArgs Properties:

      Command: The Data Command to be executed.

      Errors: The errors generated by the .NET Data Provider

      Row: The DataReader to be updated

      StatementType: The type of Command tobe executed.The possiblevalues are Select, Insert Delete, and Update

      Status: The UpdateStatus of the Command

      TableMapping: The DataTableMap ping used by the update

  3. OnRowUpdated Event

The OnRowUpdated event is raised after the Update method executes the appropriate command against the data source. The event handler for this event is either passed an SqlRowUpdatedEventArgs or an OleDbRowUpdatedEventArgs argument, depending on the Data Provider.



// Assumes that connection is a valid SqlConnection object.
SqlDataAdapter sda = new SqlDataAdapter(
"SELECT EmpID, EmpName FROM Emp", connection);
// Add handlers.
sda.RowUpdating += new SqlRowUpdatingEventHandler(OnRowUpdating);
sda.RowUpdated += new SqlRowUpdatedEventHandler(OnRowUpdated);
// Set DataAdapter command properties, fill DataSet, modify DataSet.
sda.Update(ds, "Emp");
// Remove handlers.
sda.RowUpdating -= new SqlRowUpdatingEventHandler(OnRowUpdating);
sda.RowUpdated -= new SqlRowUpdatedEventHandler(OnRowUpdated);
protected static void OnRowUpdating(
object sender, SqlRowUpdatingEventArgs args)
if (args.StatementType == StatementType.Delete)
System.IO.TextWriter tw = System.IO.File.AppendText("Deletes.log");
"{0}: Customer {1} Deleted.", DateTime.Now, 
 args.Row["EmpID", DataRowVersion.Original]);
protected static void OnRowUpdated(
object sender, SqlRowUpdatedEventArgs args)
if (args.Status == UpdateStatus.ErrorsOccurred)
args.Row.RowError = args.Errors.Message;
args.Status = UpdateStatus.SkipCurrentRow;
Previous Home Next