I have a doubt that maybe it's silly ... But it takes a little bit of peace.
When I have a ClientDataset
, a MemoryTable
or a Query
, how do I get the value of a field using FieldByName()
or the variable associated with the field?
In the example below, I get the last ID of a field in the database and differentiate the two ways to get the query value:
- Mode 1: FieldByName
-
Mode 2: associated variable
fDm.fdqHistorico.Open; iId: = 0;
if fDm.fdqHistorico.RecordCount > 0 then begin iId := fDm.fdqHistorico.FieldByName('his_id').AsInteger; // modo 1 iId := fDm.fdqHistoricohis_id.AsInteger; // modo 2 end; Inc(iId);
Are there any performance differences or anything else? Or is it just the same?