• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1121
  • Last Modified:

How to delete (remove picture) blob from a Firebird 2.0 blobfield using clientdataset.

I'd like to know how to remove picture from a blob field.

I tried to create an empty memory stream and copy that to clientdatasets blob field.

That removed picture cds but after applyupdates the picture got back (never went away).

Pekka
procedure TEtusivu.IWButton1Click(Sender: TObject);
var
   strBlob, strTmp: TStream;
begin
  try
   cdsBlobtest.Edit;
   strBlob := cdsBlobtest.CreateBlobStream(cdsBlobtest.FieldByName('Image'), bmWrite);
   strTmp := TMemoryStream.Create;
   strBlob.CopyFrom(strTmp,0);
   cdsBlobtest.Post;
   cdsBlobtest.ApplyUpdates(0);
  finally
    strBlob.Free;
    strTmpfree; 
  end;
 
end;

Open in new window

0
ppaunio
Asked:
ppaunio
1 Solution
 
chunky1Commented:
Hi,
I have never tried this but how about editing the record and assigning Null to the field something like:

cdsBlobtest.Edit
cdsblobtest.fieldvalues['Image']:=null;
cdsblobset.post;

Might be worht a try.

Paul.
0
 
Geert GOracle dbaCommented:
or use a sql statement in a query

UPDATE TABLE SET FIELD = NULL WHERE ID = 1
0
 
JohnjcesCommented:
Try also..

cdsBlobtest.FieldByName('Image').asVariant := '';

Have edit above and post below of course. This does work for me.

John
0
 
ppaunioAuthor Commented:
Yes this worked. Have to remember to put 'Variants' in the uses section.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now