DataRowVersion

DataRow.' data-guid="c6b9b05f4fce1d18bbcaadcd749bc2c9">描述 DataRow 的版本。

命名空間:  System.Data
組件:  System.Data (在 System.Data.dll 中)
publicenum DataRowVersion
  成員名稱 說明
受 XNA Framework 支援 Original 資料列含有原始值。
受 XNA Framework 支援 Current 資料列含有目前的值。
受 XNA Framework 支援 Proposed 資料列含有建議值。
受 XNA Framework 支援 Default DataRowState.' data-guid="1d0f2bedee82659da9afddf8de284c92">DataRowState 的預設版本。DataRowState value of Added, Modified or Deleted, the default version is Current.' data-guid="46a297738d616edddec1c5dd2d309efc">對於 AddedModified  Current  DataRowState值,預設的版本為 DeletedDataRowState value of Detached, the version is Proposed.' data-guid="d16ef08a82ceef9ef0c44a226303b074">對於 Detached  DataRowState 值,版本則為Proposed

DataRowVersion values are used when retrieving the value found in a DataRow using Item or the GetChildRows of the DataRow object.' data-guid="2e0ba54d7d124e84cf7183f802a6c314">在使用 DataRow 物件的 Item  GetChildRows 來擷取在 DataRow 中發現的值時,會使用 DataRowVersion 值。

DataRowVersion informs you what version of a DataRow exists.' data-guid="10ed6b86a046c0b819e8ee4aa903b945">DataRowVersion 會告知您存在哪一個版本的 DataRow版本會在下列狀況下變更:

  • DataRow object's BeginEdit method, if you change the value, the Current and Proposed values become available." data-guid="53d4c010ce3c8032a4beafa9dbdbb56b">在呼叫 DataRow 物件的 BeginEdit 方法之後,如果您變更值,則 Current  Proposed 值會變成可用的。

  • DataRow object's CancelEdit method, the Proposed value is deleted." data-guid="d1961856ae81db2d203538b7cd10bb48">在呼叫 DataRow 物件的 CancelEdit 方法之後,會刪除 Proposed 值。

  • DataRow object's EndEdit method, the Proposed value becomes the Current value." data-guid="f8e2bd0f669c22125d9d67237ada6efa">在呼叫 DataRow 物件的 EndEdit 方法之後,Proposed 值會變成 Current 值。

  • DataRow object's AcceptChanges method, the Original value becomes identical to the Current value." data-guid="c4fd48aa66edad91c2ec3ecd2bfc9fa5">在呼叫 DataRow 物件的 AcceptChanges 方法之後,Original 值會變成和 Current 值相同。

  • DataTable object's AcceptChanges method, the Original value becomes identical to the Current value." data-guid="c86f7db006e65dcf5c8b30adba76cca8">在呼叫 DataTable 物件的 AcceptChanges 方法之後,Original 值會變成和 Current 值相同。

  • DataRow object's RejectChanges method, the Proposed value is discarded, and the version becomes Current." data-guid="e114a0111666ff5a317a79a9fd2070bf">在撥號後DataRow物件的RejectChanges方法中, Proposed值會捨棄,而且版本變得Current

DataRowVersion of a DataRow before invoking the AcceptChanges method.' data-guid="53429d5d41a57e248f8fc5e9e8c5dd1f">下列範例會在叫用 (Invoke) AcceptChanges 方法之前,先檢查 DataRow  DataRowVersion

privatestaticvoid CheckVersionBeforeAccept()
	{
		//Run a function to create a DataTable with one column.
		DataTable dataTable = MakeTable();

		DataRow dataRow = dataTable.NewRow();
		dataRow["FirstName"] = "Marcy";
		dataTable.Rows.Add(dataRow);

		dataRow.BeginEdit();
		// Edit data but keep the same value.
		dataRow[0] = "Marcy";
		// Uncomment the following line to add a new value.// dataRow(0) = "Richard"
		Console.WriteLine(string.Format("FirstName {0}", dataRow[0]));

		// Compare the proposed version with the current.if (dataRow.HasVersion(DataRowVersion.Proposed)) {
			if (object.ReferenceEquals(dataRow[0, DataRowVersion.Current], dataRow[0, DataRowVersion.Proposed])) {
				Console.WriteLine("The original and the proposed are the same.");
				dataRow.CancelEdit();
			} else {
				dataRow.AcceptChanges();
				Console.WriteLine("The original and the proposed are different.");
			}
		}
	}

	privatestatic DataTable MakeTable()
	{
		// Make a simple table with one column.
		DataTable dt = new DataTable("dataTable");
		DataColumn firstName = new DataColumn("FirstName", Type.GetType("System.String"));
		dt.Columns.Add(firstName);
		return dt;
	}
posted @ 2012-11-13 19:14  perock  阅读(678)  评论(0编辑  收藏  举报