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


Editing Disconnected Data
Previous Home Next

The various objects in ADO.NET that compose the disconnected part of ADO.NET , have ability to make edits or modifications to themselves. there are mainly three kinds of modification operations that can be perform on disconnected data:

  • Add new rows
  • Modify existing rows
  • Delete existing rows

Add New Rows

There are two ways to add a new row to a DataTable, and two ways to add existing rows (from other DataTables or Detached rows) to a DataTable.

  1. The first way assumes thate we have a schema or at least a structure preloaded to the DataTable.


    rowInQuestion = StudentTable.NewRow();
    rowInQuestion["StudentID"] = 4;
    rowInQuestion["SudentName"] = "Ashish";
  2. The second method to add a new DataRow into a DataTable is to use the LoadDataRow method. Load data row method allows you to add a new DataRow and set its various values in one convenient method call.


    object[] rowVals = {"4", "Ashish"} ;
    StudentTable.LoadDataRow(rowVals, false);


Modify Existing Rows

Two methods exist for adding existing DataRows to a DataTable. The first is the ImportRow method, which simply takes a DataRow as a parameter, and the second is the Merge method, which merges two sets of disconnected data (DataSet, DataTable, DataRow array, etc.)

  1. The first way of modifying rows, DataRowState at the end of this edit would be Modified


    rowInQuestion = StudentTable.Rows[0];
    rowInQuestion["StudentName"] = "Anil";
  2. There second way of modifying rows, The DataRow object has a method called BeginEdit,and a matching method called EndEdit.we can modify the rows between these two method calls and difference is that all the changes are buffered until you call EndEdit. If, in case you change your mind, you call CancelEdit instead, all the changes are rolled back.


    rowInQuestion = StudentTable.Rows[0];
    rowInQuestion["StudentName"] = "Aditya";
    rowInQuestion.EndEdit() ;
    rowInQuestion = StudentTable.Rows[0];
    rowInQuestion.ItemArray = new object[] {null, "kamal"} ;

Delete Existing Rows

using delete method we can delete the row

rowInQuestion = StudentTable.Rows[1];

Another way of removing a row is by using either the Remove or RemoveAt method on the DataRowCollection object (DataTable.Rows is of DataRowCollection type)

StudentTable.Remove(rowInQuestion) ;
// or
StudentTable.RemoveAt(1) ;

The DataRowVersion Enumeration Description
Current This will give you the current value stored inside a column.
Original This allows you to fetch the original value stored inside a column.
Proposed This allows you to fetch the proposed value after a BeginEdit and update but before an EndEdit.
Default This retrieves the value as if the wasn’t specified
Previous Home Next