[Mono-bugs] [Bug 74631][Nor] New - DataView.Delete() method is not decreasing the row count

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 16 Apr 2005 06:20:45 -0400 (EDT)


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 appasamy@rediffmail.com.

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

--- shadow/74631	2005-04-16 06:20:45.000000000 -0400
+++ shadow/74631.tmp.21816	2005-04-16 06:20:45.000000000 -0400
@@ -0,0 +1,117 @@
+Bug#: 74631
+Product: Mono: Class Libraries
+Version: 1.1
+OS: Red Hat 9.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: appasamy@rediffmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: DataView.Delete() method  is not  decreasing  the row count 
+
+Description of Problem:
+
+DataView.Delete() method  is not  decreasing  the row count by one after 
+calling it. So DataView.Count value remains unaffected after deleting a 
+row. 
+
+Steps to reproduce the problem:
+
+1. Create a table in your DBMS
+
+2. Execute the following program:
+   (Change neccessary fields as required) 
+
+3. 
+ using System;
+ using System.Data;
+ using System.Data.Odbc;
+ 
+ public class Test 
+ {
+    public static void Main(string[] args)
+    {
+		
+       // Change connection string as per your configuration
+       string connectionString = 
+          "DSN=MYSQL;" +
+          "UID=root;" +
+          "PWD=";
+       OdbcConnection dbcon;
+       dbcon = new OdbcConnection (connectionString);
+       dbcon.Open ();
+       OdbcDataAdapter adapter = new OdbcDataAdapter ("select * from    
+new", dbcon );
+       DataSet dataset = new DataSet ("new");
+       adapter.Fill (dataset);
+       DataView dataView = new DataView (ds.Tables[0]);
+       
+       // 'new'  table in this sample contains 6 records
+       Console.WriteLine ("RowCount Before delete: " + dataView.Count);
+       dataView.AllowDelete = true;
+
+       // Deleting the first row
+
+       dataView.Delete (0);
+
+       Console.WriteLine ("RowCount After delete: " + dataView.Count); 
+        
+       // Checking for remaining rows
+
+       string cname = String.Empty; 
+       for (int i=0; i< dataView.Count; i++)
+	{
+           cname = dataView1[i]["E_Name"].ToString();
+	   Console.WriteLine("Name: "+cname);
+        }
+       dbcmd.Dispose ();
+       dbcmd = null;
+       dbcon.Close ();
+       dbcon = null;
+    }
+}
+
+
+
+Actual Results:
+
+RowCount Before delete: 6
+RowCount After delete: 6
+
+Unhandled Exception: System.Data.DeletedRowInaccessibleException: Deleted 
+row information cannot be accessed through the row.
+in <0x001ea> System.Data.DataRow:get_Item (int,System.Data.DataRowVersion)
+in <0x0004a> System.Data.DataRow:get_Item 
+(System.Data.DataColumn,System.Data.DataRowVersion)
+in <0x00015> System.Data.DataRow:get_Item (System.Data.DataColumn)
+in <0x00046> System.Data.DataRowView:get_Item (string)
+in <0x00210> Test:Main (string[])
+
+
+Expected Results:
+
+RowCount Before delete: 6
+RowCount After delete: 5
+
+Name: Sabari
+Name: Appasamy
+Name: Nishanth
+Name: Rajkumar
+Name: Appu
+
+
+How often does this happen? 
+
+Always
+
+Additional Information:
+
+The above code is tested with  MS-ACCESS and C# in windows and the 
+results are as expected.