[Mono-bugs] [Bug 76394][Nor] New - Odbc.Decimal Problems,
when reading and as Parameter
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Mon Oct 10 07:16:25 EDT 2005
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 timo-mono at pokorra.de.
http://bugzilla.ximian.com/show_bug.cgi?id=76394
--- shadow/76394 2005-10-10 07:16:25.000000000 -0400
+++ shadow/76394.tmp.6961 2005-10-10 07:16:25.000000000 -0400
@@ -0,0 +1,67 @@
+Bug#: 76394
+Product: Mono: Class Libraries
+Version: 1.1
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: timo-mono at pokorra.de
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Odbc.Decimal Problems, when reading and as Parameter
+
+first problem:
+In OdbcDataReader.cs, Version 48798, line: 674 and 675
+buffer=new byte[bufsize]; // According to sqlext.h, use SQL_CHAR for decimal.
+ret=libodbc.SQLGetData(hstmt, ColIndex, col.SqlCType, buffer, bufsize, ref
+outsize);
+
+col.SqlCType is of type NUMERIC, but as the comment states, it should be
+SQL_C_TYPE.CHAR. Then it works fine for me.
+
+Otherwise the exception comes up:
+
+FormatException
+ "Invalid character at position 0"
+in <0x004e6> System.Decimal:stripStyles (System.String s, NumberStyles
+style, System.Globalization.NumberFormatInfo nfi, System.Int32 decPos,
+System.Boolean isNegative, System.Boolean expFlag, System.Int32 exp)
+in <0x000ac> System.Decimal:Parse (System.String s, NumberStyles style,
+IFormatProvider provider)
+in <0x00015> System.Decimal:Parse (System.String s)
+in <0x002d3> System.Data.Odbc.OdbcDataReader:GetValue (Int32 ordinal)
+in (wrapper remoting-invoke-with-check)
+System.Data.Odbc.OdbcDataReader:GetValue (int)
+
+Second Problem:
+ODBCParameter for Decimal and Numeric is not implemented in Version 51463
+of OdbcParameter.cs.
+From previous versions of the file, this changes work for me:
+in GetNativeSize():
+ case OdbcType.Numeric:
+ case OdbcType.Decimal:
+ return 19;
+
+In CopyValue():
+case OdbcType.Decimal:
+case OdbcType.Numeric:
+{
+ // for numeric, the buffer is a packed decimal struct.
+ // ref http://www.it-faq.pl/mskb/181/254.HTM
+ int [] bits = Decimal.GetBits (Convert.ToDecimal (Value));
+ buffer = new byte [19]; // ref sqltypes.h
+ buffer [0] = Precision;
+ buffer [1] = (byte) ((bits [3] & 0x00FF0000) >> 16); // scale
+ buffer [2] = (byte) ((bits [3] & 0x80000000) > 0 ? 2 : 1); //sign
+ Buffer.BlockCopy (bits, 0, buffer, 3, 12); // copy data
+ for (int j = 16; j < 19; j++) // pad with 0
+ buffer [j] = 0;
+ Marshal.Copy (buffer, 0, _nativeBuffer, 19);
+ return;
+}
More information about the mono-bugs
mailing list