diff options
author | Sureshkumar T <suresh@mono-cvs.ximian.com> | 2005-10-14 11:10:30 +0400 |
---|---|---|
committer | Sureshkumar T <suresh@mono-cvs.ximian.com> | 2005-10-14 11:10:30 +0400 |
commit | be4ca4ac72bf8eace2f25542fdabf9164327c0f2 (patch) | |
tree | ed461f21b1a367aed7df2145ef0863795d794112 /mcs/class/System.Data/System.Data.Odbc | |
parent | 1101bf999f80d86076ea1bac8f07b2cd47d404c1 (diff) |
2005-10-14 Sureshkumar T <tsureshkumar@novell.com>
* OdbcParameter.cs (CopyValue): Add support for Numeric & Decimal
parameters.
svn path=/trunk/mcs/; revision=51702
Diffstat (limited to 'mcs/class/System.Data/System.Data.Odbc')
-rw-r--r-- | mcs/class/System.Data/System.Data.Odbc/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs | 17 |
2 files changed, 20 insertions, 2 deletions
diff --git a/mcs/class/System.Data/System.Data.Odbc/ChangeLog b/mcs/class/System.Data/System.Data.Odbc/ChangeLog index c58756c51f8..bda1d12cf4a 100644 --- a/mcs/class/System.Data/System.Data.Odbc/ChangeLog +++ b/mcs/class/System.Data/System.Data.Odbc/ChangeLog @@ -1,3 +1,8 @@ +2005-10-14 Sureshkumar T <tsureshkumar@novell.com> + + * OdbcParameter.cs (CopyValue): Add support for Numeric & Decimal + parameters. + 2005-10-08 Sureshkumar T <tsureshkumar@novell.com> * OdbcCommand.cs (BindParameters): Copy the parameter Value after diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs index be2463b0de3..844ff952707 100644 --- a/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs +++ b/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs @@ -316,8 +316,9 @@ namespace System.Data.Odbc return Marshal.SizeOf (typeof (int)); case OdbcType.BigInt: return Marshal.SizeOf (typeof (long)); + case OdbcType.Decimal: case OdbcType.Numeric: - return Value.ToString ().Length; + return 19; case OdbcType.SmallInt: return Marshal.SizeOf (typeof (Int16)); case OdbcType.TinyInt: @@ -392,8 +393,20 @@ namespace System.Data.Odbc case OdbcType.BigInt: Marshal.WriteInt64 (_nativeBuffer, Convert.ToInt64 (Value)); return; + case OdbcType.Decimal: case OdbcType.Numeric: - throw new NotImplementedException (); + // 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; case OdbcType.SmallInt: Marshal.WriteInt16 (_nativeBuffer, Convert.ToInt16 (Value)); return; |