Zoran
User
 Junior Boarder
| Posts: 16 |   | Karma: 0 |
|
Re:How to insert and read BLOB field
|
|
Posted: 2007/04/04 14:19 |
|
|
|
|
Hi Dmitry
Never mind. I figured it out. If somebody is interested, here are details...
[for Memo]
SQL in TDQuery1:
update Sys set Memo1=:mmo where Id=2
|
paramater 'mmo' is ftMemo data type
TDQuery1.ParamByName('mmo').Value := Memo1.Lines.Text;
TDQuery1.ExecSQL;
|
[for images]
SQL in TDQuery2:
update Sys set Graphic=:graphic where Id=2
|
paramater 'graphic' is ftBlob data type
TDQuery2.ParamByName('graphic').LoadFromFile('D:\Images\Fun\Face.bmp', ftBlob);
TDQuery2.ExecSQL;
|
[to retrieve image]
bs: TStream;
fs: TFileStream;
bs := TStream.Create;
bs := TDClientDataSet1.CreateBlobStream(TDClientDataSet1.FieldByName('Graphic'), bmRead);
bs.Position := 0;
fs := TFileStream.Create('D:\Face.bmp', fmCreate);
fs.CopyFrom(bs, bs.Size);
fs.Free;
bs.Free;
|
Simple (when you know how )......
Zoran
Post edited by: Diman, at: 2007/04/04 22:32
|
|