Free TField in db lazarus / 16-Databases ---------------------------------------------------------------------- cappe · 2018-10-26 08:48 I have a project as an example:   TForm1 = class(TForm)     Button1: TButton;     DBConnection: TZConnection;     ZQuery1: TZQuery;     ZQuery1BAC1: TStringField;     ZQuery1BAC2: TLongintField;     ZQuery1BAC3: TStringField;     ZQuery1BAC4: TStringField;     ZQuery1BAC5: TDateTimeField;     ZQuery1BAC6: TStringField;     ZQuery1BAC7: TStringField;     ZQuery1ID: TStringField;     procedure Button1Click(Sender: TObject);   private   public   end; procedure TForm1.Button1Click(Sender: TObject); begin   ZQuery1.Fields[1].Free;        <-- Is correct? end;          The question is if "ZQuery1.Fields[1].Free" is correct to free the tfield numer 1? ---------------------------------------------------------------------- Mike.Cornflake · 2018-10-26 09:11 You shouldn't have to manually free any of the fields shown here.  The ones you created in the designer will be automatically free'd when you close the form (the form is their parent) The list of fields held by ZQuery are automatically created when you call zquery.open, and automatically free'd when you call zquery.close. What is it you are trying to achieve? ---------------------------------------------------------------------- cappe · 2018-10-26 09:23 I have to find the correct way to free only a TField from code. I need to do this ---------------------------------------------------------------------- Thaddy · 2018-10-26 11:58 removing a field from an existing SQL database can only be done by a SQL  query. Although it is possible to do that using e.g. tiOPF. Which abstracts away that query to Pascal code. Usually it is better to NOT remove the field, but write a new query that omits the field. It requires a database restructure to actually remove it. Which is I think what you mean. ---------------------------------------------------------------------- cappe · 2018-10-26 14:05 In fact it would seem to be true, once canceled it works, but in the subsequent operations it gives me some problems. Unless someone knows how to do it.