Field.DataSize returns a wrong length lazarus / 16-Databases ---------------------------------------------------------------------- tintinux · 2010-10-27 12:35 Hi On Lazarus 0.28.2. Why does the function Field.DataSize returns the actual length +1 for a ftString or other ? This is obvious from the code of dsparams.inc. But Why +1 ??  Isn't it a bug ? Bye Tintinux Code: [Select]Function TParam.GetDataSize: Integer; begin   Result:=0;   case DataType of     ftUnknown  : DatabaseErrorFmt(SUnknownParamFieldType,[Name],DataSet);     ftBoolean  : Result:=SizeOf(WordBool);     ftInteger,     ftAutoInc  : Result:=SizeOf(Integer);     ftSmallint : Result:=SizeOf(SmallInt);     ftWord     : Result:=SizeOf(Word);     ftTime,     ftDate     : Result:=SizeOf(Integer);     ftDateTime,     ftCurrency,     ftFloat    : Result:=SizeOf(Double);     ftString,     ftFixedChar,     ftMemo,     ftADT      : Result:=Length(AsString)+1;     ftBytes,     ftVarBytes : if VarIsArray(FValue) then                    Result:=VarArrayHighBound(FValue,1)+1                  else                    Result:=0;     ftBlob,     ftGraphic..ftTypedBinary,     ftOraClob,     ftOraBlob  : Result:=Length(AsString);     ftArray,     ftDataSet,     ftReference,     ftCursor   : Result:=0;   else     DatabaseErrorFmt(SBadParamFieldType,[Name],DataSet);   end; ---------------------------------------------------------------------- clauslack · 2010-10-27 19:45 I think that Field.DataSize is the size of the buffer. Field.Size has the correct length. Regards ---------------------------------------------------------------------- Lacak2 · 2010-10-28 04:49 Exactly see also http://docwiki.embarcadero.com/VCL/XE/en/DB.TField.DataSize