Mega Code Archive

 
Categories / C# Tutorial / ADO Net
 

DataRowState manipulation

using System; using System.Collections.Generic; using System.Text; using System.Data; using System.IO; using System.Runtime.Serialization.Formatters.Binary;   class Program   {     static void Main(string[] args)     {       DataTable temp = new DataTable("Temp");       temp.Columns.Add(new DataColumn("TempColumn", typeof(int)));       DataRow row = temp.NewRow();                  Console.WriteLine("After calling NewRow(): {0}", row.RowState);       temp.Rows.Add(row);       Console.WriteLine("After calling Rows.Add(): {0}", row.RowState);       row["TempColumn"] = 10;       Console.WriteLine("After first assignment: {0}", row.RowState);       temp.AcceptChanges();       Console.WriteLine("After calling AcceptChanges: {0}", row.RowState);       row["TempColumn"] = 11;       Console.WriteLine("After first assignment: {0}", row.RowState);       temp.Rows[0].Delete();       Console.WriteLine("After calling Delete: {0}", row.RowState);     }   }