Delphi XE8 and SQLServer 2017.
I have a query (TADOQuery) connected to a SQLServer database. After opening the dataset (TADOQuery.Open), if I call TADOQuery.FieldByName('X').AsCurrency it returns 0, but if I call TADOQuery.FieldByName('X').AsFloat it returns 12.65 (correct value). Looking at the specific field in the table, the type is numeric(18,4). What's wrong?
This code runs the otherthing:
with TADOQuery1 do
begin
SQL.Clear;
SQL.Add('select X from Table1');
Open;
if FieldByName('X').AsCurrency > 0 then // <- Here is the problem
do something
else
do otherthing;
end;
This code runs the something:
with TADOQuery1 do
begin
SQL.Clear;
SQL.Add('select X from Table1');
Open;
if FieldByName('X').AsFloat > 0 then // <- Here is the problem
do something
else
do otherthing;
end;
Cannot reproduce this behavior.
here is a MRE, amount is a numeric(18,4) in table Tbl_test :