DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Accept Changes Of Data Row

03.22.2012
| 2412 views |
  • submit to reddit
        How to Commits all the changes made to this a since the AcceptChanges was called.

private void demoacceptchanges(){
    DataTable mtable = CreateTable();
    DataRow mrow;
 
    // New row.
    mrow = mtable.NewRow();

    Console.WriteLine("new row" + mrow.RowState);
 
 
    mRow.Delete();
    Console.WriteLine("Deleted row " + mrow.RowState);
 }
 
 private DataTable CreateTable(){

    // Make a simple table with one column.
    DataTable dt = new DataTable("mTable");
    DataColumn colname = new DataColumn("name", Type.GetType("System.String"));
    dt.Columns.Add(colname);
    return dt;
 }