views:

35

answers:

1

Hello,

I need to read a nvarchar(max) field from a SQL Server 2008 database using Delphi 6 and ADO. I can handle the unicode text just fine but it seems the ADO component is "preconverting" the string to code page before I even get to have a look at it.

I've tried accessing the field as a TBlobField but it gives me the converted version as well: I'm storing 10 bytes of data representing 5 chinese characters and BlobSize returns 5.

Could anyone suggest a way to get the raw memory from the blob field without having it converted ?

+1  A: 

I found it. It turned out to be really simple: Open the dataset as if it was a normal field and the do the following:

AQuery.FieldByName('LocalText').SetFieldType(ftWideString);
WSBuffer := (AQuery.FieldByName('LocalText') as TWideStringField).Value;

(WSBuffer is a WideString type).

Stephane