i have a Form name brazil and button save(Button3Click) and 4 Tedit field (Edit1Coach,Edit2Vice,Edit3Captain,Edit4Keeper) to Insert values in it when user click button save this what should happen
procedure TBrazil.Button3Click(Sender: TObject);
var
FieldList: TList<TStringField> ;
Field: TField;
Paramters: DataBase_Param;
i : integer ;
x : Variant ;
begin
FieldList := TList<TStringField>.Create;
try
//Paramters.Create(Self);
FieldList.Add(TStringField.Create(nil));
FieldList.Add(TStringField.Create(nil));
FieldList.Add(TStringField.Create(nil));
FieldList.Add(TStringField.Create(nil));
FieldList.Add(TStringField.Create(nil));
Field := FieldList[0];
Field.FieldName :='Coach';
Field.Value:=(Edit1Coach.Text);
Field := FieldList[1];
Field.FieldName := 'Vice';
Field.Value :=(Edit2Vice.Text);
Field := FieldList[2];
Field.FieldName := 'Captain';
Field.Value :=(Edit3Captain.Text);
Field := FieldList[3];
Field.FieldName := 'Keeper_coach';
Field.Value :=(Edit4Keeper.Text);
Field := FieldList[4];
Field.FieldName := 'Country';
Field.Value :=('Brazil');
save_record_to_Db_theory(Paramters, FieldList ) ;
finally
for Field in FieldList do
Field.Free;
FieldList.Free;
end;
end;
I created in this method list of TStringField and every value will insert in it the problem is that when i try to set the value of Field.Value
acess violation error accure althought that when i set the value of Field.FieldName
it assigned succifully hat should happen ??
i changed the list from TList<Field>
to TList<TStringField>
and i change Field.Value
with Field.AsString
and Field.text
but always this error appear
and checked if (FieldList.Count > 0) and (FieldList[i] is TStringField)
and they always return true and the same error happen again