Hello Wagner;
Would you help me to use a proper type casting for loading the TBlob field(s) into table when posting the data?
Assume the table has this structure:
CREATE TABLE [dbo].[CUSTOMERS](
[ID] [int] NOT NULL,
[NAME] nvarchar NULL,
[COUNTRY] varchar NULL,
[RATE] [decimal](6, 4) NULL,
[CONTRY_CODE] varchar NULL,
[CREATEDDATE] varchar NULL,
[MAPIMAGE] varbinary NULL,
)
So the mapping class is something like this:
TCustomer = class
Id: Integer;
Name: string;
Country: string;
Rate:Double;
CountryCode:string;
CreatedDate:string;
MapImage:TBlob;
.
.
End;
I’ve to use a “varbinarry(max)” in my table data field, but not sure what type casing could be used to load them properly in insert?
Query.SQL.Text := 'INSERT INTO CUSTOMERS VALUES (:id, :name, :country, :rate, :code, :createddate, :blobmap)';
Query.ParamByName('id').AsInteger := Customer.Id;
Query.ParamByName('name').AsString := Customer.Name;
Query.ParamByName('country').AsString := Customer.Country;
Query.ParamByName('rate').AsFloat := Customer.Rate;
Query.ParamByName('code').AsString := Customer.CountryCode;
Query.ParamByName('createddate').AsString := Customer.CreatedDate;
Query.ParamByName('blobmap').LoadFromStream(aStream, ftBlob); // .AsAnsiString := Customer.Map.AsUnicodeString;
In JSON call, I could send an image data in base64 encoded data… but no when I decode and inserted to database / table is not a write values.
Thank you.
Saeid.