Page 1 of 1

Error with ntext field type

Posted: Thu 05 Apr 2007 08:38
by siatc1
I have a table that contains ntext field type. If the field contain some unicode character or symbols such as € or £, it will hit "Stream read error" when that field is being display in grid or dbEditBox.

There is no error when I use TADODataSet and do the same thing.

I'm currently using Delphi 6 and SDAC 3.80.0.37.

Thanks

Posted: Fri 06 Apr 2007 12:40
by Jackson
Both ADO and SDAC convert NTEXT field values to string when you try to access it using the TMemoFiels.AsString method.
There is no TWideMemoField type in Delphi 6.
So the data is always truncated. To access data as widestring, use the following code:

Code: Select all

uses
  MemData;
 ...
var
  Blob: TBlob;
  Value: widestring;
begin
  Blob := MSQuery1.GetBlob('FieldName');
  if Blob.IsUnicode then
    Value := Blob.AsWideString;
end;
Standard DB-aware controls do support Unicode. You should use any third party controls, for example TNT controls.

Posted: Mon 09 Apr 2007 05:55
by siatc1
Perhaps I did not explain it clearly.

The issue here is that there is not error when I use TADODataSet for the same field, but when using SDAC the error appears.

If the problem is with Delphi 6 TWideMemoField, then TADODataSet should also have that error.

Thanks

EvgeniyM wrote:Both ADO and SDAC convert NTEXT field values to string when you try to access it using the TMemoFiels.AsString method.
There is no TWideMemoField type in Delphi 6.
So the data is always truncated. To access data as widestring, use the following code:

Code: Select all

uses
  MemData;
 ...
var
  Blob: TBlob;
  Value: widestring;
begin
  Blob := MSQuery1.GetBlob('FieldName');
  if Blob.IsUnicode then
    Value := Blob.AsWideString;
end;
Standard DB-aware controls do support Unicode. You should use any third party controls, for example TNT controls.

Posted: Tue 10 Apr 2007 11:15
by Jackson
We couldn't reproduce the problem with "Stream read error" exception.
Please send us (evgeniym*crlab*com) a complete small test project to reproduce the problem;
include definition of your own database objects and script for populating tables with data or send us a database backup.
Also specify exact version of Microsoft SQL Server and OLE DB provider you use. You can see it the Info sheet of TMSConnection Editor.

Posted: Mon 16 Apr 2007 10:14
by Jackson
Thank you for information.
We have reproduced the problem.
There is a bug in Delphi 6 Vcl with converting WideString to AnsiString in the function CharFromWChar (System.pas).
We have implemented the workaround of this problem.
This workaround will be available in the next build of SDAC 3.
Please watch for announcements at the forum.