Board index » delphi » work with TBCDField

work with TBCDField


2003-09-19 10:00:53 AM
delphi40
I have a project used with TADODataset, the dataset bind a MS SQL table
include numeric(28, 5) Field(A).When i get the field on design state, the
type of field(A) returned is TBCDField with property precision = 28 and size
= 5.But the Value of Field(A) will be trunct to 4 fraction(0.2222) when i
input 5 fraction number(0.22222). what is the matter? Working environment is
delphi6 + MS SQL.please somebody tell me and help me?
 
 

Re:work with TBCDField

"moritenw" <XXXX@XXXXX.COM>writes
Quote
please somebody tell me and help me?
Sounds like you're using .AsCurrency to manipulate the field. Currency is
restricted to 4 decimal places so you should look at .AsFloat instead.
Cheers,
Ignacio
 

Re:work with TBCDField

That was not as you thouht. the value of property currency of Field(A) is
false.
I do input the value in a TDBGrid. The value was trunct after input the
value and leave the cell.
"Ignacio Vazquez" <ivazquezATorioncommunications.com>дʼ
Quote
"moritenw" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...
>please somebody tell me and help me?

Sounds like you're using .AsCurrency to manipulate the field. Currency is
restricted to 4 decimal places so you should look at .AsFloat instead.

Cheers,
Ignacio


 

Re:work with TBCDField

"moritenw" <XXXX@XXXXX.COM>wrote
Quote
I have a project used with TADODataset, the dataset bind
a MS SQL table include numeric(28, 5) Field(A).When i get
the field on design state, the type of field(A) returned is
TBCDField with property precision = 28 and size>= 5.
But the Value of Field(A) will be trunct to 4 fraction(0.2222)
when i input 5 fraction number(0.22222). what is the matter? ...
I notice in D7's Help:
"The IDE uses two different field types for representing BCD fields:
TBCDField and TFMTBCDField. TBCDField uses the Currency (Delphi) or
System::Currency (C++) type to manipulate BCD values. This is faster
than storing and manipulating the value using a true BCD type, but
limits the precision of the BCD values it can support to 4 decimal
places and 20 significant digits."
Thus it would appear that your dataset should be using the
field type TFMTBCDField. Can you change it?
Regards, JohnH
 

Re:work with TBCDField

thks for your respond. I had found the how to resovle it. just set the
property of TADODataSet EnableBCD to False, the it will generate the
TfloatField type rather than TBCDField type.
"John Herbster (TeamB)" <XXXX@XXXXX.COM>????
Quote

"moritenw" <XXXX@XXXXX.COM>wrote
>I have a project used with TADODataset, the dataset bind
>a MS SQL table include numeric(28, 5) Field(A).When i get
>the field on design state, the type of field(A) returned is
>TBCDField with property precision = 28 and size>= 5.
>But the Value of Field(A) will be trunct to 4 fraction(0.2222)
>when i input 5 fraction number(0.22222). what is the matter? ...

I notice in D7's Help:

"The IDE uses two different field types for representing BCD fields:
TBCDField and TFMTBCDField. TBCDField uses the Currency (Delphi) or
System::Currency (C++) type to manipulate BCD values. This is faster
than storing and manipulating the value using a true BCD type, but
limits the precision of the BCD values it can support to 4 decimal
places and 20 significant digits."

Thus it would appear that your dataset should be using the
field type TFMTBCDField. Can you change it?
Regards, JohnH