[Mono-bugs] [Bug 565616] InvalidCastException when storing a not IConvertible value in a string datacolumn.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Dec 17 10:01:08 EST 2009


http://bugzilla.novell.com/show_bug.cgi?id=565616

http://bugzilla.novell.com/show_bug.cgi?id=565616#c1


--- Comment #1 from Hubert FONGARNAND <informatique.internet at fiducial.fr> 2009-12-17 15:01:07 UTC ---
Quick and dirty patch to fix the issue

Index: System.Data.Common/DataContainer.cs
===================================================================
--- System.Data.Common/DataContainer.cs    (révision 148704)
+++ System.Data.Common/DataContainer.cs    (copie de travail)
@@ -160,6 +160,8 @@

             if (_type.IsInstanceOfType (value)) {
                 return value;
+            } else if (Type.GetTypeCode (_type) == TypeCode.String) {
+                return (Convert.ToString (value));
             } else if (value is IConvertible) {
                 switch (Type.GetTypeCode(_type)) {
                     case TypeCode.Int16:
@@ -168,8 +170,6 @@
                         return (Convert.ToInt32 (value));
                     case TypeCode.Int64:
                         return (Convert.ToInt64 (value));
-                    case TypeCode.String:
-                        return (Convert.ToString (value));
                     case TypeCode.Boolean:
                         return (Convert.ToBoolean (value));
                     case TypeCode.Byte:

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list