Recent

Author Topic: [Solved] Different behaviour of Blob type  (Read 397 times)

luca

  • Jr. Member
  • **
  • Posts: 73
[Solved] Different behaviour of Blob type
« on: June 28, 2022, 11:19:31 am »
Hi,
I've updated a program to last official version of Lazarus.
I must change this code
Code: Pascal  [Select][+][-]
  1. var
  2.   i:integer;
  3.   a:String;  
  4. begin
  5. ....
  6.   qry.ParamByName('VAL').AsBlob:=a;
  7. ....
  8. end;
  9.  
to this one
Code: Pascal  [Select][+][-]
  1. var
  2.   i:integer;
  3.   a:TBytes;  
  4. begin
  5. ....
  6.   qry.ParamByName('VAL').AsBlob:=a;
  7. ....
  8. end;
  9.  

I know probably last version is better than the previous one, BUT I cannot compile the old code because I receive this error:

unit1.pas(470,43) Error: Incompatible type for arg no. 1: Got "AnsiString", expected "TBytes"

So my question is: what has changed from Lazarus 2.0.12 to Lazarus 2.2.0?

Regards
Luca
« Last Edit: June 28, 2022, 11:24:55 am by luca »

luca

  • Jr. Member
  • **
  • Posts: 73
Re: [Solved] Different behaviour of Blob type
« Reply #1 on: June 28, 2022, 11:26:34 am »
I found this in the user Changes 3.2.0
https://wiki.freepascal.org/User_Changes_3.2.0#TBlobData_opaque_type_reworked_to_TBytes

Quote
TBlobData opaque type reworked to TBytes
Old behaviour: TBlobData was declared as Ansistring
New behaviour: TBlobData is declared as TBytes
Reason for change: Delphi compatibility. Also helps to avoid possible code page recodings.
Remedy: If your application used TBlobData as a string, you can use AsString for parameters, or convert to TBytes.


 

TinyPortal © 2005-2018