I’m storing some information to my Access database, one parameter is a BLOB field, in this case an image, loaded into a Timage.
I’m using this code to save it:
var
AStream : TMemoryStream;
begin
AStream := TMemoryStream.Create;
try
Image1.Picture.Graphic.SaveToStream(AStream);
AStream.Position := 0;
if Adotable1.Active then
begin
Adotable1.Edit;
TBlobField(Adotable1.FieldByName('Termograma')).LoadFromStream(AStream);
Adotable1.Post;
end;
finally
AStream.Free;
adotable1.Append;
adotable1['Data']:= datetimepicker1.Date;
adotable1['Temax']:= edit4.Text;
adotable1['Temin']:= edit5.Text;
adotable1['Descrição da Posição']:= memo1.Text;
adotable1['Comentários']:= memo2.Text;
adotable1.Post;
But I also have other information I’m storing by clicking in the same button like the “append” part.
What happens is that when I press the save button, this information does not get stored in the same ID on the database.
How do I correct this problem?
You’re editing the current record, saving the image to it, appending a new record, and saving the rest of the info to that new record. I think you intend to add an entire new record, add the image and data to that new one, and then save those changes.
Try this instead: