Bug with Memo fields and MSSQL Text columns

(tobygroves) #1

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 on Delphi 10.2 Tokyo with FireDAC.


(RemObjects) #2

Thanks, logged as bugs://79941

(tobygroves) #3

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

(EvgenyK) #4

pls update uDAFireDACDriver.pas as

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

(RemObjects) #5

bugs://79941 got closed with status fixed.

(tobygroves) #6

Yep that’s got it, thanks :slight_smile: