Page 1 of 1

TWideMemoField and LoadFromStream

Posted: Sat 26 May 2007 20:46
by aliemrei
hi;

I am using SDAC 4.xx pro and my problem is TWideMemoField.savetostream and loadfromstream.

my report tool is fastreport 4 and I am saving to database (fr3 xml file)
using 3.xx trial when my field has TMemoField after upgrade to SDAC 4 fieldtype chanced to TWideMemoField.

now my data is like "?????????•???????????????4????????????????????????????????????•??......"

sorry my bad english and please help me.

...
var
ms :TMemoryStream;
begin
ms := TMemoryStream.Create;
frx.savetostream(ms); // frx is fastreport 4 (TfrxReport)
ms.Position := 0;
MSDataset1.edit;
MSDataset1WideMemoField.loadfromstream(ms);
MSDataset1.post;
....
....
end;

Thanks and Best Regards
Emre

Posted: Tue 29 May 2007 12:38
by Jackson
Support of the TWideMemoField class was addeed in BDS 2006.
We have supported this functionality in SDAC 4. Now no conversion is performed when you write non-Unicode data to Unicode field.
You should change the column data type on the server (use TEXT data type instead of NTEXT), or perform conversion from ANSI strings to Unicode strings in your application.
There are several ways to perform such conversion:

1. Use TWideMemoField.AsString property to assign the value to it:
MSDataset1WideMemoField.AsString := sValue;
In such case you should convert the value from TMemoryStream into a string variable.

2. Use the following construction:

Code: Select all

uses
  MemData...;
...
var
  ms :TMemoryStream;
  Blob: TBlob;
begin
  ms := TMemoryStream.Create;
  frx.savetostream(ms); // frx is fastreport 4 (TfrxReport)
  ms.Position := 0;
  MSDataset1.edit;
  Blob := MSDataset1.GetBlob(MSDataset1WideMemoField);
  Blob.Clear;
  Blob.IsUnicode := False;
  Blob.LoadFromStream(ms);
  MSDataset1.post;
end;
 ...

Posted: Thu 31 May 2007 06:32
by aliemrei
thanks. :P