saving/loading from blob file

sadkat

Member
i'm trying to put a word document in a blob field of a table. i'm using that code:

procedure TForm1.BB1Click(Sender: TObject);
var oStream : TBlobStream;
begin
oStream := nil;
if OleContainer1.State osEmpty then
begin
try
OracleDataSet1.Open;
try
OracleDataSet1.Edit;
OracleDataSet1.FieldByName('id').AsString := 'PRV';
oStream := TBlobStream.Create(OracleDataSet1.FieldByName('fitxer') as TBlobField, bmReadWrite);
OleContainer1.SaveToStream(oStream);
OracleDataSet1.Post;
ShowMessage('BLOB SAVED');
except
ShowMessage('BLOB NOT SAVED');
end;
finally
oStream.Free;
OracleDataSet1.Close;
end;
end;
end;
 
oooops i forgot to say that this code gave me that error message:

hope someone could explain me how to work with the blob fields. Thanks.
 
The TBlobStream casts the dataset of the field to a TBDEDataSet. The TOracleDataSet descends from TDataSet, not from TBDEDataSet. Therefore you get this error.

However, you should be able to use TOracleDataSet.CreateBlobStream to overcome this problem. This will obviously not typecast the dataset, as it is a method of the TOracleDataSet class.

------------------
Marco Kalter
Allround Automations
 
Back
Top