[Mono-bugs] [Bug 47883][Wis] New - Incorrect comparison in DataRow.cs (Easy to solve)

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 25 Aug 2003 12:44:26 -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 sergio-blanco@iespana.es.

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

--- shadow/47883	2003-08-25 12:44:26.000000000 -0400
+++ shadow/47883.tmp.10266	2003-08-25 12:44:26.000000000 -0400
@@ -0,0 +1,41 @@
+Bug#: 47883
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System.Data
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sergio-blanco@iespana.es               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Incorrect comparison in DataRow.cs (Easy to solve)
+
+In DataRow.cs (System.Data) there is a overloaded method:
+
+    public bool IsNull (DataColumn column)
+    {
+      return (this[column] == null);
+    }
+    [more IsNull methods]
+
+It returns true if the column specified of the row is null, otherwise
+returns false. But I've found a problem here, the comparison made is wrong
+, when a column is null it cotains DBNull.Value and not null. 
+
+As we can see, the method SetNull (from DataRow also) that makes a Column
+null, assigns DBNull.Value instead of null:
+
+protected void SetNull (DataColumn column)
+    {
+      this[column] = DBNull.Value;
+    }
+
+So all these methods IsNull (overloaded) must have a comparison like this:
+
+      return (this[column] == DBNull.Value);