Display (and update) NVARCHAR(MAX) fields


I have a MSSQL database with a number of NVARCHAR(MAX) fields that contains text. When imported as classes by the Data Manager, they are mapped as Blob and decorated with [DBTypeMemo]

So far, that works. Now, I have placed the containing entity in a package, dropped a TAureliusDataSet on it and loaded the class from the package before creating the fields from the FieldDefs. Then, I used visual binding on a TListView to map the fields to the columns and ran the application.

Unfortunately, content of theses field are not display, being replaced with "(OBJECT)" instead.

I then went and changed the type of the field (and fieldDef) to "ftMemo" but then I only get the first letter. I though it was reading the (unicode) string as an ansistring so I went and changed the types to ftWideMemo but I have the same result: only the first letter of the text is displayed.

What am I doing wrong? What is the correct way to use NVARCHAR(MAX) fields in Aurelius so they are display correctly when bound to controls (both when beaing read and when updated from the control)?

Hello Mr. Grobety,

Could you please first isolate a little bit further and check what happens if binding the field to a TMemo using datasource, and also what happens if you read the content directly from the field using AsString and AsWideString? With the field being configured as ftMemo and ftWideMemo?


Thank you for your answer. I tried the following:
- Using regular ADO components to bind the field either through LiveBinding or using TDBmemo works fine
- Using Aurelius dataset to bind the field through LiveBinding or using a TDBMemo results in either the content being replaced with (WIDESTRING) or with only the first letter being displayed.

Is that what you wanted me to try ?

I found a sollution but it's far from ideal: I had to write a handler for the "OnGetText" and "OnSetText" events:

  if (Sender is TBlobField) and ((sender as TBlobField).BlobType=ftWideString) then
    Text := (Sender as TBlobField).AsWideString;

  if (Sender is TBlobField) and ((sender as TBlobField).BlobType=ftWideString) then
    (Sender as TBlobField).AsWideString := Text;

I forgot to add that I also had to manually set the blob field type to ftWideString

Is it possible that you send us a project reproducing the issue? This way we can go directly to the point and let you know exactly what is the correct way to do it and why.


I built a test project for demonstration and found out that, in my original code, I had not actually set the FieldsDef "BlobType" property to "ftWideMemo" as I originally thought. Once I did that, the text in the NVARCHAR(MAX) dield displayed correctly when used through livebinding