TWideMemoField and LoadFromStream

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
aliemrei
Posts: 15
Joined: Sat 27 Jan 2007 09:12

TWideMemoField and LoadFromStream

Post by aliemrei » Sat 26 May 2007 20:46

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

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Tue 29 May 2007 12:38

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;
 ...

aliemrei
Posts: 15
Joined: Sat 27 Jan 2007 09:12

Post by aliemrei » Thu 31 May 2007 06:32

thanks. :P

Post Reply