Solved

Client Data Set - Wide Memo

Posted on 2013-06-12
6
1,829 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

622 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