TWideMemoField and TMemoField AsString

TeeGrid VCL / FMX for Embarcadero RAD Studio, Delphi, C++ Builder and Lazarus Free Pascal.
Post Reply
REH Outsourcing
Newbie
Newbie
Posts: 25
Joined: Tue Mar 13, 2018 12:00 am

TWideMemoField and TMemoField AsString

Post by REH Outsourcing » Fri Oct 05, 2018 8:10 am

Delphi version: Seattle (Not tested in Tokyo)
TTeeGrid version: VCL & FMX Registered version-1.06
Multidevice Application (FMX)
Platform: WIN32
DataSet:TFDQuery

Good Morning,

When a TField (associated with a TDataSet) belongs to one of these TWideMemoField or TMemoField classes, when calling the TVirtualDBData.AsString method, it does not return the contents of the field, it returns the text (WIDEMEMO), this happens because the method is being called TField.DisplayText and not TField.AsSTring.
I suggest you check the class and if it is one of the two classes that I mention, call the TField.AsString method.

The solution could be the following (it is the one I have in production), within the method TVirtualDBData.AsString:

Code: Select all

      // Eliminar esta linea
      //result:= tmp.DisplayText; // <-- return Field AsString
      // Substituirla por esta.
      if (tmp is TMemoField) or (tmp is TWideMemoField) then
        {REH FIX}{Si se utiliza DisplayText se obtiene la cadena '(WIDEMEMO)', en vez del contenido del campo.}
        result:=tmp.AsSTring // DisplayText muestra '(WIDEMEMO)'
      else
        result:= tmp.DisplayText; // <-- return Field AsString

Marc
Site Admin
Site Admin
Posts: 930
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: TWideMemoField and TMemoField AsString

Post by Marc » Thu Oct 11, 2018 7:32 am

Many thanks for the input. Change submitted as issue/fix: #2111

http://bugs.teechart.net/show_bug.cgi?id=2111

Regards,
Marc
Steema Support

Post Reply