Subject BlobStream needs to be freed before IBOQuery post
Author bmckenna6
I've apparently solved my 'Dataset not in Edit or Insert Mode' error
message in the following code:

The query's current parameterized SQL:
'SELECT FROM TABLE1 WHERE ID = :ID'
and RequestLive = True

if IBOquery.Active then
begin
if IBOquery.State <> dsEdit then
IBOquery.Edit;
if IBOquery.State = dsEdit then
begin
BlobStrmSave := IBOquery.CreateBlobStream(IBOquery.FieldByName
('NOTES'), bmWrite);
try
Ed.Lines.SaveToStream(BlobStrmSave);
IBOquery.Post;
Ed.Modified := False;
finally
// this call returns 'Dataset not in edit or insert mode' ???
FreeAndNil(BlobStrmSave);
end;
end;
end;

Changing it to

try
Ed.Lines.SaveToStream(BlobStrmSave);
FreeAndNil(BlobStrmSave);
IBOquery.Post;
Ed.Modified := False;
finally

end;

results in error free operation. This is apparently how TDataset
(hence IBOQuery, I presume) and IBX require it. However, ISTM a bit
awkward to free the BlobStrmSave before the 'finally'. Any thoughts?