ftAutoinc in Memdataset lazarus / 16-Databases ---------------------------------------------------------------------- P.curtis · 2020-05-01 06:47 How can I use ftAutoinc in MemDataset? I am used to Autoinc in MariaDB where the result, as integer, is incremented per record, I would like the same in MemDataset. ---------------------------------------------------------------------- wp · 2020-05-01 07:08 AFAIK, TMemDataset is very simply and does not support AutoInc. Try TBufDataset instead, it is more complete. ---------------------------------------------------------------------- P.curtis · 2020-05-01 08:15 Cant get my head round it. I have attached a small demo program could someone have a look at whats wrong ---------------------------------------------------------------------- wp · 2020-05-01 08:26 Create the fields at runtime. Designtime code still seems to be buggy... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);begin  with BufDataset1 do begin  FieldDefs.Clear;    FieldDefs.Add('fnIDX', ftAutoInc);    FieldDefs.Add('fnDATA', ftString, 10);    CreateDataset;  end;end; ---------------------------------------------------------------------- P.curtis · 2020-05-01 08:47 OK. That works, thanks, but creates a new question. When I dynamically create my fields how can I specify presicion for ftFloat fields? ---------------------------------------------------------------------- wp · 2020-05-01 09:03 TFieldDefs also has method AddFieldDef which returns the created FieldDef so that you can access all properties. A bit more typing, though, or create your own function for it: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);begin  with BufDataset1 do begin  FieldDefs.Clear;    with FieldDefs.AddFieldDef do    begin      Name := 'fnIDX';      DataType := ftAutoInc;    end;    with FieldDefs.AddFieldDef do    begin      Name := 'fnDATA';      DataType := ftString;      Size := 10;    end;    with FieldDefs.AddFieldDef do    begin      Name := 'fnFLOAT';      DataType := ftFloat;      Precision := 3;    end;    CreateDataset;  end;end; ---------------------------------------------------------------------- P.curtis · 2020-05-01 09:06 Job done. Thanks.