[Mono-bugs] [Bug 66925][Nor] New - DbDataAdapter does not fill rows with null DateTime column values

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 27 Sep 2004 18:08:58 -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 rscaletta@augustmack.com.


--- shadow/66925	2004-09-27 18:08:58.000000000 -0400
+++ shadow/66925.tmp.27619	2004-09-27 18:08:58.000000000 -0400
@@ -0,0 +1,57 @@
+Bug#: 66925
+Product: Mono: Class Libraries
+Version: unspecified
+OS: All
+OS Details: mono version 1.0
+Status: NEW   
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: rscaletta@augustmack.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: DbDataAdapter does not fill rows with null DateTime column values
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+I am connecting to a Microsoft SQL Server database and attempting to select
+some rows.  When I attempt to select some rows that have null values in a
+DateTime column, the FillError event is raised and no rows are added to the
+On MS .NET framework 1.1, no FillError is raised.
+Steps to reproduce the problem:
+1. Create a table with a DateTime column
+2. Create a row with null for that column
+3. Call Fill() using a data adapter.
+Actual Results:
+The new row you created is returned.
+Expected Results:
+No rows are returned.  Additionally, the FillError event is raised.
+How often does this happen? 
+Every time
+Additional Information:
+Problem lies in System.Data/System.Data.Common/DataContainer.cs
+At line 1102, it calls 
+  base.SetValue(index,record.GetDateTime(field));
+If the value is null, GetDateTime will throw a SqlNullValueException.  The
+exception is caught in DbDataAdapter, which makes it VERY hard to figure
+out what is going on.
+Change 1102 to
+    this.SetValue(index, record.GetValue(field));
+The SetValue method in DateTimeDataContainer already safely converts any
+object to a DateTime.  Additionally, the GetValue method will not throw an
+exception, it will just return DBNull.