[Mono-bugs] [Bug 67916][Nor] New - (n)text field with empty value is considered DBNull

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 10 Oct 2004 11:55:54 -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 gert.driesen@pandora.be.

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

--- shadow/67916	2004-10-10 11:55:54.000000000 -0400
+++ shadow/67916.tmp.19183	2004-10-10 11:55:54.000000000 -0400
@@ -0,0 +1,55 @@
+Bug#: 67916
+Product: Mono: Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data.SqlClient
+AssignedTo: rodrigo@novell.com                            
+ReportedBy: gert.driesen@pandora.be               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: (n)text field with empty value is considered DBNull
+
+In Mono, an (n)text field containing an empty string value is returned as 
+a DBNull field while on MS.NET its returned as empty string (as it 
+should).
+
+To reproduce this issue compile the following code (and replace the IP 
+address of the server and the credentials with your own) :
+
+using System;
+using System.Data.SqlClient;
+
+class EmptyNTextFieldTest {
+    [STAThread]
+    static void Main(string[] args) {
+        using (SqlConnection sqlConnection = new SqlConnection()) {
+            sqlConnection.ConnectionString 
+= "server=192.168.0.9;database=master;user id=sa;pwd=;";
+            sqlConnection.Open();
+
+            SqlCommand sqlCommand = sqlConnection.CreateCommand();
+            sqlCommand.CommandText = "CREATE TABLE #MonoTest (NAME 
+ntext)";
+            sqlCommand.ExecuteNonQuery();
+
+            sqlCommand.CommandText = "INSERT INTO #MonoTest VALUES ('')";
+            sqlCommand.ExecuteNonQuery();
+
+            sqlCommand.CommandText = "SELECT * FROM #MonoTest";
+            SqlDataReader dr = sqlCommand.ExecuteReader();
+            while (dr.Read()) {
+                Console.WriteLine(dr["NAME"].GetType().FullName);
+            }
+        }
+    }
+}
+
+On Mono, this test app will output "System.DBNull", while on MS.NET 
+you'll get "System.String".