I found the problem. before you had the insertion method as follows:
procedure Tform33.Insert_data_ART;
var i:integer;
sql:string;
ms:TStream;
blopfield:Tfield;
begin
ShowMessage(inttostr(num_regs_fb_ART));
ms:=TMemoryStream.Create;
for I := 1 to num_regs_fb_ART do
begin
try
Artigos_imgTable.Active:=false;
Artigos_imgTable.Close;
sql:= ('INSERT INTO Artigos_img (Codigo_arm,Referencia,Designacao1,'+
'preco1,imagem) ' +
'VALUES' +
' (''' + Codigo_arm[i] + ''', ' +
'''' +Referencia[i] + ''', ' +
'''' + Designacao1[i] + ''', ' +
'' + preco1[i] + ');' );
Artigos_imgTable.CommandText:=sql;
ms.Position:=0;
try
Artigos_imgTable.active:=true;
with Artigos_imgTable do
begin
Insert;
blopfield:=FieldByName('imagem');
ms:=CreateBlobStream(blopfield,bmWrite);
BinaryAsBITMap[I].SaveToStream(ms);
end;
except
on e:exception do
infotext(e.Message);
end;
try
Artigos_imgTable.CommandText:=sql;
Artigos_imgTable.ExecSQL(true);
except on E: Exception do
ShowMessage(e.message);
end;
finally
ms.Free;
end;
end;
infoText('Dados Atualizados...');
end;
So as it is of type BLOB as the first data entry is a 0 or a 1 and as SQLite wraps the field type to the data type it enters, the database assumed that I was inserting a long int .
The correct way to insert a BLOB is as follows:
procedure Tform33.Insert_data_ART;
var i:integer;
sql:string;
ms:TStream;
LTransaction: TDBXTransaction;
LParams: TParams;
begin
for I := 1 to num_regs_fb_ART do
begin
sql:= ('INSERT INTO Artigos (Codigo_arm,Referencia,Designacao1,'+
'preco1,Imagem) ' +
'VALUES' +
' (''' + Codigo_arm[i] + ''', ' +
'''' +Referencia[i] + ''', ' +
'''' + Designacao1[i] + ''', ' +
'''' + preco1[i] + ''', ' +
':Imagem)' );
try
LTransaction:=Gia_1C.BeginTransaction;
LParams:=TParams.Create(nil);
ms:=TMemoryStream.Create;
BinaryAsBITMap[I].SaveToStream(ms);
try
LParams.CreateParam(ftBlob,'Imagem',ptinput);
LParams.ParamByName('Imagem').LoadFromStream(ms,ftblob);
Gia_1C.Execute(SQL,Lparams);
Gia_1C.CommitFreeAndNil(LTransaction);
finally
FreeAndNil(ms);
FreeAndNil(Lparams);
end;
except on E: Exception do
infoText(e.Message);
end;
end;
infoText('Dados Atualizados...');
end;