Bug with Memo fields and MSSQL Text columns

I’ve discovered a bug with memo fields and MSSQL Text columns.

If you have an MSSQL table with a column of type Text, this is brought into the schema as a Memo field, quite correctly.

If you then attempt to append a new record to this table, the text in this field is corrupted. Looking at it, it appears as if there are null characters in between each of the original characters which suggests a unicode/non-unicode mismatch problem somewhere.

Obviously, as both MSSQL Text columns and schema Memo fields are non-unicode, this should work correctly. I appreciate that the Text column type is deprecated but it should still work and there are some places where we’re not yet able to migrate over to unicode NVARCHAR(MAX) columns.

I’ve reproduced this with a small text app created using the VCL Application wizard which I’ll mail over in a moment. There’s also an SQL script file in there to create the database.

I’m using DA 9.3.105.1351 on Delphi 10.2 Tokyo with FireDAC.

Thanks.

Thanks, logged as bugs://79941

Thanks, if I could have a hotfix when you’ve tracked it down, that’d be great.

pls update uDAFireDACDriver.pas as

uses
uROEncoding,
...
procedure SetADParamValuesFromDA(ADAParams: TDAParamCollection;
  AADParams: TFDParams; ASetType: Boolean);
..
   if oDAPar.DataType = datMemo then                //added
     buf := StringToAnsiBytes(oDAPar.AsString) else //added
   buf := VariantToBytes(oDAPar.Value);

bugs://79941 got closed with status fixed.

Yep that’s got it, thanks :slight_smile:

After upgrading to the latest version of DA, this appears to be broken again but in a slightly different way.

The field is now populating with a series of question marks, usually seven of them.

Use the same test program I submitted earlier, it exhibits the problem.

thx for report.
if you revert workaround for this issue, i.e. change

            if oDAPar.DataType = datMemo then
              buf := StringToAnsiBytes(oDAPar.AsString)
            else
              buf := VariantToBytes(oDAPar.Value);

with

buf := VariantToBytes(oDAPar.Value);

will it solve this issue?

Yep that appears to work