using System;
using System.Data;
namespace conn
{
	/// <summary>
	/// Class1 的摘要说明。
	/// </summary>
	class Class1
	{
		Class1()
		{
		}
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			//
			// TODO: 在此处添加代码以启动应用程序
			//
			Class1 cl1=new Class1();
			cl1.DemonstrateAcceptChanges();
		}
		private void DemonstrateAcceptChanges()
		{
			//Run a function to create a DataTable with one column.
			DataTable myTable = MakeTable();
			DataRow myRow;
 
			// Create a new DataRow.
			myRow = myTable.NewRow();
			// Detached row.
			myTable.AcceptChanges();
			Console.WriteLine("New Row:myrow.state " + myRow.RowState);
 
			myTable.Rows.Add(myRow);
			// New row.
			myTable.AcceptChanges();
			Console.WriteLine("AddRow:myRow.RowState " + myRow.RowState);		
 
			myRow["FirstName"] = "Scott";
			// Modified row.
			Console.WriteLine("Modified " + myRow.RowState);
			myTable.AcceptChanges();
			// Unchanged row.
			Console.WriteLine("AcceptChanges: myRow.RowState " + myRow.RowState);
			myRow.Delete();
			// Deleted row.
			Console.WriteLine("Deleted " + myRow.RowState);
			myTable.AcceptChanges();
			// Unchanged row.
			Console.WriteLine("AcceptChanges: myRow.RowState " + myRow.RowState);
			myTable.AcceptChanges();
			// Unchanged row.
			Console.WriteLine("AcceptChanges: myRow.RowState " + myRow.RowState);
			myTable.AcceptChanges();
			// Unchanged row.
			Console.WriteLine("AcceptChanges: myRow.RowState " + myRow.RowState);
		}
 
		private DataTable MakeTable()
		{
			// Make a simple table with one column.
			DataTable dt = new DataTable("myTable");
			DataColumn dcFirstName = new DataColumn("FirstName", Type.GetType("System.String"));
			dt.Columns.Add(dcFirstName);
			return dt;
		}

	}
}
