[Solved] SQLite Size property lazarus / 16-Databases ---------------------------------------------------------------------- OmegaX · 2020-08-18 23:53 Hi, I'm loading a query with TSQLQuery. Then what I do is assigning it to a TBufDataset. With this function: 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 CopyFromDataset(var BuffDataset: TBufDataset; DataSet: TDataSet; CopyData: Boolean);Var  I  : Integer;  F,F1,F2 : TField;  L1,L2  : TList;  N : String;  OriginalPosition: TBookMark;begin with BuffDataset do begin  Clear;  Close;  For I:=0 to Dataset.FieldCount-1 do   begin   F:=Dataset.Fields[I];   if F<>nil then   begin         try             if (F.FieldDef.DataType=ftMemo) or               (F.FieldDef.DataType=ftString)then                  TFieldDef.Create( FieldDefs,F.FieldName,ftString,256,F.Required,F.FieldNo)              else                  TFieldDef.Create(FieldDefs,F.FieldName,F.DataTyp e,F.Size,F.Required,F.FieldNo);         except              TFieldDef. Create(FieldDefs,F.FieldName,F.DataType,F.Size,F.Required,F.FieldNo);         end;       end;   end;  CreateDataset;  If CopyData then  begin    Open;    L1:=TList.Create;    Try      L2:=TList.Create;    Try        For I:=0 to FieldDefs.Count-1 do          begin          N:=FieldDefs[I].Name;          F1:=FieldByName(N);          F2:=DataSet.FieldByName(N);          L1.Add(F1);          L2.Add(F2);          end;        DisableControls;        Dataset.DisableControls;      OriginalPosition:=Dataset.GetBookmark;        Try          Dataset.Open;          Dataset.First;          While not Dataset.EOF do          try            begin                Append;              For I:=0 to L1.Count-1 do                  begin                      F1:=TField(L1[i]);                      F2:=TField(L2[I]);                    if not F2.IsNull then                      Case F1.DataType of                        ftFixedChar,                        ftString   : F1.AsString:=F2.AsString;                        ftBoolean  : F1.AsBoolean:=F2.AsBoolean;                        ftFloat    : F1.AsFloat:=F2.AsFloat;                        ftLargeInt : F1.AsInteger:=F2.AsInteger;                        ftSmallInt : F1.AsInteger:=F2.AsInteger;                        ftInteger  : F1.AsInteger:=F2.AsInteger;                        ftDate     : F1.AsDateTime:=F2.AsDateTime;                        ftTime     : F1.AsDateTime:=F2.AsDateTime;                        ftDateTime : F1.AsDateTime:=F2.AsDateTime;                        ftMemo     : F1.AsString:=F2.AsString;                        else         F1.AsString:=F2.AsString;                  end                  else                      F1.Value:=NULL;               end;            Try              Post;            except              Cancel;            Raise;            end;            Dataset.Next;            end;         except on e:exception do              N:=e.message;          end;        Finally          DataSet.GotoBookmark(OriginalPosition); //Return to original record          Dataset.EnableControls;          EnableControls;        end;      finally        L2.Free;      end;    finally      l1.Free;    end;  end; end;end; 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                 TFieldDef.Create(FieldDefs,F.FieldName,ftString,256,F.Required,F .FieldNo) As you can see for strings the Size is harcoded to 256. When I really want to have the size that's in the 'Length' property for each field that is a property of the field. That field limits the number of characters the string can have. So I can read that property and set the MaxLength in the TEdit controls. If I change the line 256 by F.Size my program stops working. Any ideas? ---------------------------------------------------------------------- dsiders · 2020-08-19 00:35 https://forum.lazarus.freepascal.org/index.php/topic,49721.msg361848.h tml#msg361848 https://forum.lazarus.freepascal.org/index.php/topic,40253.msg278029.h tml#msg278029 ---------------------------------------------------------------------- OmegaX · 2020-08-19 13:18 Thanks dsiders. I don't fully understand the links, but I'm solving it using PRAGMA table_info, reading the length from there and assigning it to TEdit controls. Not touching the code I shown. Thanks