EConvertError on Post
Posted: Sat 05 May 2007 06:14
Hello,
I have a MSTable that is referencing a table with a decimal(30,15) column. The field is being seen as a TFMTBCDField (which is what I want). When I try to edit the value in the decimal field I get a EConvertError when Post is called. Here is the code that is changing the value:
var
bcd: TBcd;
s: string;
begin
with MSTable1 do begin
First;
s := FieldByName('exchange_rate').AsString;
s := '1' + s;
bcd := StrToBcd(s);
Edit;
if FieldByName('exchange_rate') is TFMTBCDField then
TFMTBCDField(FieldByName('exchange_rate')).AsString := s
else
FieldByName('exchange_rate').AsString := s;
Post; // This is where the EConvertError is generated
end;
Please note that this is only a test and the above logic is just to validate the functionality of the components. I have also tried:
...
TFMTBCDField(FieldByName('exchange_rate')).Value := bcd
...
The value that I was testing is 0.72222 and the value I am updating it to is 10.72222 (Well within the limits of a BCD and decimal(30,15).
Any suggestions will be greatly appreciated.
Tom
I have a MSTable that is referencing a table with a decimal(30,15) column. The field is being seen as a TFMTBCDField (which is what I want). When I try to edit the value in the decimal field I get a EConvertError when Post is called. Here is the code that is changing the value:
var
bcd: TBcd;
s: string;
begin
with MSTable1 do begin
First;
s := FieldByName('exchange_rate').AsString;
s := '1' + s;
bcd := StrToBcd(s);
Edit;
if FieldByName('exchange_rate') is TFMTBCDField then
TFMTBCDField(FieldByName('exchange_rate')).AsString := s
else
FieldByName('exchange_rate').AsString := s;
Post; // This is where the EConvertError is generated
end;
Please note that this is only a test and the above logic is just to validate the functionality of the components. I have also tried:
...
TFMTBCDField(FieldByName('exchange_rate')).Value := bcd
...
The value that I was testing is 0.72222 and the value I am updating it to is 10.72222 (Well within the limits of a BCD and decimal(30,15).
Any suggestions will be greatly appreciated.
Tom