Hi;
I store decimal values in ms sql server 2005 of type decimal (28,14). When I
try to get values from that field, for example "566.68015492220000000" with
the code
string temp=myReader["total"].ToString();
I get the value "566.68010000000000000", I mean I get the value with only
few digits of precision.
What should I do to get the exact value from db?
Thanks a lot...
Michael Nemtsev - 01 Oct 2007 23:10 GMT
Hello basulasz,
use Math.Round(566.68015, 2)
and u will get 566.68
---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
b> Hi;
b>
b> I store decimal values in ms sql server 2005 of type decimal (28,14).
b> When I try to get values from that field, for example
b> "566.68015492220000000" with the code
b>
b> string temp=myReader["total"].ToString();
b>
b> I get the value "566.68010000000000000", I mean I get the value with
b> only few digits of precision.
b>
b> What should I do to get the exact value from db?
b>
b> Thanks a lot...
b>
basulasz - 02 Oct 2007 05:36 GMT
I don't want to round the value. If I have "566.68015492220000000" stored in
db, I want to get "566.68015492220000000" again. But I get
"566.68010000000000000". I need the correct value, not a rounded value
> Hello basulasz,
>
[quoted text clipped - 23 lines]
> b> Thanks a lot...
> b>
Patrice - 02 Oct 2007 10:47 GMT
What if you try to get the decimal data type and then convert to a string ?
Else I'll try to repro...
--
Patrice
> Hi;
>
[quoted text clipped - 12 lines]
>
> Thanks a lot...
basulasz - 02 Oct 2007 11:30 GMT
how can I get decimal data type?
> What if you try to get the decimal data type and then convert to a string ?
> Else I'll try to repro...
[quoted text clipped - 18 lines]
> >
> > Thanks a lot...
Ged - 02 Oct 2007 11:39 GMT
Decimal number = Convert.ToDecimal( myReader["total"] );

Signature
Ged Moretta
www.appsense.com
-----------------------------------------------------------------------
This signature isn't automatic. I have to type it manually every time.
> how can I get decimal data type?
>
[quoted text clipped - 23 lines]
>> >
>> > Thanks a lot...
Kevin Spencer - 02 Oct 2007 11:41 GMT
Decimal d = myReader.GetDecimal(myReader.GetOrdinal("total"));

Signature
HTH,
Kevin Spencer
Microsoft MVP
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
> Hi;
>
[quoted text clipped - 12 lines]
>
> Thanks a lot...
basulasz - 02 Oct 2007 12:05 GMT
Ok. I am done. Thanks...
> Decimal d = myReader.GetDecimal(myReader.GetOrdinal("total"));
>
[quoted text clipped - 14 lines]
> >
> > Thanks a lot...