1

I have a DataSource connected to a ClientDataSet. The database file is stored local on my computer in a binary MyBase file.

The ClientDataSet has 1 Blob field and i want to store images in this field. When changing the image, the database increases its size instead of deleting the old content completly. Can someone give me an example what to do to remove the old content in a Blob field completly instead of increasing the size in my database?

Here is a small example for testing. Every time I press the button, the DB file increases its size. No new Record is created.

procedure TForm1.Button1Click(Sender: TObject);
begin
ClientDataSet1.Edit;
TBlobField(ClientDataSet1.FieldByName('blob')).Clear;
TBlobField(ClientDataSet1.FieldByName('blob')).LoadFromFile('C:\Users\xxx\Desktop\example.bmp');
ClientDataSet1.Post;
ClientDataSet1.SaveToFile(ExtractFilePath(ParamStr(0)) + 'DB.cds', dfBinary);
end;

When I run if TBlobField(ClientDataSet1.FieldByName('blob')).IsNull directly after the clear command, it says that its empty.

Chris
  • 306
  • 1
  • 4
  • 17
  • 1
    https://stackoverflow.com/questions/22213481/tclientdataset-used-as-in-memory-dataset-is-it-possible-to-apply-the-updates-i – Dave Nottage Aug 08 '17 at 00:58
  • Thank you very much. This solved my problem. Make an Answer and I will upvote you – Chris Aug 08 '17 at 06:01

0 Answers0