Re: how to use DB_NUMERIC in OLEDB ?
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Wed, 23 Nov 2005 22:54:17 +0000 (UTC)
davidshen (davidshen@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:
> i want to use a DB_NUMERIC variable to update my MSSQL2K, the number i
> want to send is 55.5, and i set DB_NUMERIC using the following code:
> DB_NUMERIC num;
> num.precision=5;
> num.scale=2;
> num.sign=1;
> long tmp = long (55.5*100) // which is 5550, 15ae in hex
> memset(num.val,0,16); // the length of num.val is 16
> memcpy(num.val, &tmp, sizeof(long));// bit copy
>
> but on the sql server side, the number it stored is 55
> what's the problem with my code?
And the column is really a decimal(5,2) on the SQL Server side?
Filling in DB_NUMERIC is non-trivial, because you need to know how
many bytes to fill in. This depends on the precision. It does not
seem to be such an error in this case, though.
You may want to look at IDataConvert, which is described in Appendix I
in the OLE DB Programmers Reference.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- Prev by Date: Re: how to use DB_NUMERIC in OLEDB ?
- Next by Date: Re: how to use DB_NUMERIC in OLEDB ?
- Previous by thread: Re: how to use DB_NUMERIC in OLEDB ?
- Next by thread: Re: how to use DB_NUMERIC in OLEDB ?
- Index(es):
Relevant Pages
|
Loading