Solved

Client Data Set - Wide Memo

Posted on 2013-06-12
6
1,711 Views
Last Modified: 2013-06-28
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.
0
Comment
Question by:GrahamDLovell
  • 3
6 Comments
 
LVL 21

Expert Comment

by:developmentguru
ID: 39246256
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
 

Author Comment

by:GrahamDLovell
ID: 39246331
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
 

Accepted Solution

by:
GrahamDLovell earned 0 total points
ID: 39265716
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
 

Author Closing Comment

by:GrahamDLovell
ID: 39283791
Problem solved, even though there could be a "less fussy" way of solving it that I have not found. Therefore = "good".
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes some very basic things about SQL Server filegroups.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now