Error with ntext field type

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
siatc1
Posts: 8
Joined: Fri 13 Jan 2006 05:58

Error with ntext field type

Post by siatc1 » Thu 05 Apr 2007 08:38

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

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

Post by Jackson » Fri 06 Apr 2007 12:40

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.

siatc1
Posts: 8
Joined: Fri 13 Jan 2006 05:58

Post by siatc1 » Mon 09 Apr 2007 05:55

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.

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

Post by Jackson » Tue 10 Apr 2007 11:15

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.

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

Post by Jackson » Mon 16 Apr 2007 10:14

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.

Post Reply