If a parameter is NULL or DBNull then its size needs to be zero otherwise the paramet...
authorNeale Ferguson <neale@sinenomine.net>
Thu, 5 Jan 2012 17:48:02 +0000 (12:48 -0500)
committerNeale Ferguson <neale@sinenomine.net>
Thu, 5 Jan 2012 17:48:02 +0000 (12:48 -0500)
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs

index 60cb4bee36cdf9ce054c308015066b509ac8b1ec..4bd857dc6e7c2d18475c4e6f5e921231e5cda3de 100644 (file)
@@ -522,6 +522,13 @@ namespace Mono.Data.Tds.Protocol
                                size = param.GetActualSize ();
                        }
 
+                       /*
+                        * If the value is null, not setting the size to 0 will cause varchar
+                        * fields to get inserted as an empty string rather than an null.
+                        */
+                       if (param.Value == null || param.Value == DBNull.Value)
+                               size = 0;
+
                        // Change colType according to the following table
                        /* 
                         * Original Type        Maxlen          New Type