Re: how to use DB_NUMERIC in OLEDB ?
- From: "Frank Hickman [MVP]" <fhickman3_NOSP@xxxxxxxxxxxxxxx>
- Date: Wed, 23 Nov 2005 11:29:47 -0500
"davidshen" <davidshen@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2D0B1716-0EBC-45BE-A079-39D9D5909427@xxxxxxxxxxxxxxxx
>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?
Why would you expect a long to hold a decimal? Try using a float, double or
long double.
--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.
.
- Follow-Ups:
- Re: how to use DB_NUMERIC in OLEDB ?
- From: Erland Sommarskog
- Re: how to use DB_NUMERIC in OLEDB ?
- Prev by Date: Re: Reg OLEDB images..
- Next by Date: Re: how to use DB_NUMERIC in OLEDB ?
- Previous by thread: ATL Provider as SQL Linked Server
- Next by thread: Re: how to use DB_NUMERIC in OLEDB ?
- Index(es):
Relevant Pages
|
Loading