Client Data Set - Wide Memo

Greek Extended characters do not "stick" in Delphi MIDAS wide memo field.

I can enter them into a wide memo, but when the field is saved to the TClientDataSet and then read again, it comes back as "?"

I can work around this by writing the memo as a fixed length wide string (with a substitute new line character), but this loses the flexibility of the memo type, which allows many lines, entirely at the user discretion.

Here is the code used to save the field:

     cdsDiction.FieldByName('WideMeaning').Assign(Meaning.lines);

Where cdsDiction is a TClientDataSet and the associated data field "WideMeaning" is a Wide Memo, and the VCL field "Meaning" is a TMemo.
GrahamDLovellAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GrahamDLovellConnect With a Mentor Author Commented:
Here is my fix for my problem:

I do not now try to directly assign a ClientDataSet WideMemo field to a TMemo. For preference, I put a TDBMemo on the form and link the TDBMemo field to the ClientDataSet via a TDataSource.

Where I also needed a Memo field on the form that is not actually linked to the TClientDataSet, I had to include some extra steps.

1. I put a TDBMemo field on the form, as above, but hid it so that the user won't to see it (e.g. naming it DBMemo).
2. I put a TMemo field on the form (e.g. naming it Memo).
3. For when I move a new row, I include the following code
  Memo.clear;
  for k := 0 to DBMemo.Lines.Count-1 do
    Memo.Lines[k] := DBMemo.Lines[k];
4. For when I make changes to the Memo field, I include the following code
  DBMemo.clear;
  for k := 0 to Memo.Lines.Count-1 do
    DBMemo.Lines[k] := Memo.Lines[k];

When converting an existing ClientDataSet Memo field to WideMemo it was necessary to use a version of the above code. (I didn't originally do that, and it has given me much grief.)

There may be a more elegant way of doing it, but this works.
0
 
developmentguruPresidentCommented:
Is this in a stand alone client dataset or is it being used along with a database table or query?  If it is, which database?

What version of Delphi are you on?  If it is on a version that handles unicode characters then you should be able to simply use AsString to assign the value.

If you are on a version prior to the use of unicode strings I can tell you that you are missing out on some amazing tools...
0
 
GrahamDLovellAuthor Commented:
It is a stand alone client dataset, saving to .cds file. However, the problem occurs before the save, in any case.

I am on the latest Delphi, XE4. Yes, I agree it has a great set of tools. That is why I am so surprised it isn't working. However, it could be that I am just making a simple mistake. That is why I included the code, which is also simple.

One of the values it doesn't appear to store properly is the unicode represented by ή. This is OK in the TMemo on input, but it gets replaced with ? if I just do next and then previous on the TDataSet

For a Memo field, I have only been able to use assign. Of course, if I use a simple AsString property I get an incompatibility of TString and string error:

    cdsDiction.FieldByName('WideMeaning').AsString := meaning.Lines;

I am not aware of any way to iterate through the TDataSet widememo field instead of making an assignment.
0
 
GrahamDLovellAuthor Commented:
Problem solved, even though there could be a "less fussy" way of solving it that I have not found. Therefore = "good".
0
All Courses

From novice to tech pro — start learning today.