[Mono-bugs] [Bug 75227][Nor] New - DataSet.GetChanges() fails when dataset includes deleted rows

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Jun 10 20:37:35 EDT 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by george.barbarosie at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=75227

--- shadow/75227	2005-06-10 20:37:35.000000000 -0400
+++ shadow/75227.tmp.2597	2005-06-10 20:37:35.000000000 -0400
@@ -0,0 +1,118 @@
+Bug#: 75227
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: george.barbarosie at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: DataSet.GetChanges() fails when dataset includes deleted rows
+
+This happens only when there's a relation in the dataset.
+
+testcase:
+
+using System;
+using System.Data;
+
+class Test {
+    public static void Main() {
+        DataSet ds = new DataSet("testds");
+
+        DataTable tbl = ds.Tables.Add("parent");
+        DataColumn col = tbl.Columns.Add("id", typeof(int));
+        col.AutoIncrement = true;
+        col = tbl.Columns.Add("data", typeof(string));
+        col.AllowDBNull = false;
+        tbl.PrimaryKey = new DataColumn[] { tbl.Columns["id"] };
+
+        tbl = ds.Tables.Add("child");
+        col = tbl.Columns.Add("id", typeof(int));
+        col.AutoIncrement = true;
+        col = tbl.Columns.Add("parent", typeof(int));
+        tbl.Columns.Add("data", typeof(string));
+        tbl.PrimaryKey = new DataColumn[] { tbl.Columns["id"] };
+
+        ds.Relations.Add("child2parent",
+                ds.Tables["parent"].Columns["id"],
+                ds.Tables["child"].Columns["parent"]);
+
+        DataRow row = ds.Tables["parent"].NewRow();
+        row["data"] = "something on parent";
+        ds.Tables["parent"].Rows.Add(row);
+
+        row = ds.Tables["child"].NewRow();
+        row["data"] = "something on child";
+        row["parent"] = 0;
+        ds.Tables["child"].Rows.Add(row);
+        ds.AcceptChanges();
+
+        row = ds.Tables["child"].Rows.Find(0);
+        row.Delete();
+
+        try {
+            ds.GetChanges();
+        } catch (Exception e) {
+            Console.WriteLine("Exception caught (1):");
+            Console.WriteLine(e);
+        }
+
+        ds.RejectChanges();
+
+        row = ds.Tables["parent"].Rows.Find(0);
+        row.Delete();
+
+        try {
+            ds.GetChanges();
+        } catch (Exception e) {
+            Console.WriteLine("Exception caught (2):");
+            Console.WriteLine(e);
+        }
+
+    }
+}
+
+Expected results: should not throw an exception;
+
+Actual results:
+
+Exception caught (1):
+System.Data.DeletedRowInaccessibleException: Deleted row information cannot
+be accessed through the row.
+in <0x000ba> System.Data.DataRow:IndexFromVersion (DataRowVersion version)
+in <0x0014a> System.Data.DataRow:GetParentRows (System.Data.DataRelation
+relation, DataRowVersion version)
+in <0x00016> System.Data.DataRow:GetParentRow (System.Data.DataRelation
+relation, DataRowVersion version)
+in <0x00015> System.Data.DataRow:GetParentRow (System.Data.DataRelation
+relation)
+in <0x000b6> System.Data.DataSet:AddChangedRow
+(System.Collections.Hashtable addedRows, System.Data.DataTable copyTable,
+System.Data.DataRow row)
+in <0x00148> System.Data.DataSet:GetChanges (DataRowState rowStates)
+in <0x0000f> System.Data.DataSet:GetChanges ()
+in <0x00457> Test:Main ()
+Exception caught (2):
+System.Data.DeletedRowInaccessibleException: Deleted row information cannot
+be accessed through the row.
+in <0x000ba> System.Data.DataRow:IndexFromVersion (DataRowVersion version)
+in <0x0014a> System.Data.DataRow:GetParentRows (System.Data.DataRelation
+relation, DataRowVersion version)
+in <0x00016> System.Data.DataRow:GetParentRow (System.Data.DataRelation
+relation, DataRowVersion version)
+in <0x00015> System.Data.DataRow:GetParentRow (System.Data.DataRelation
+relation)
+in <0x000b6> System.Data.DataSet:AddChangedRow
+(System.Collections.Hashtable addedRows, System.Data.DataTable copyTable,
+System.Data.DataRow row)
+in <0x00148> System.Data.DataSet:GetChanges (DataRowState rowStates)
+in <0x0000f> System.Data.DataSet:GetChanges ()
+in <0x00514> Test:Main ()


More information about the mono-bugs mailing list