Subject | Re: [IBO] Re: tib_image code example? |
---|---|
Author | Robert Martin |
Post date | 2015-10-06T03:28:49Z |
Hi Russell
Glad I could help. I would use a TImage as you suggest.
For what its worth I avoid building SQLs as strings where possible as it avoids dealing with special characters etc. I would do it as
SQL.Clear;
SQL.Add('insert into PICS (pic_id, pic, comment, pic_type_id, target_id)');
SQL.Add('values (GEN_ID(GEN_PICS, 1), :pic, :comment, :pic_type_id, :target_id');
p.s. I would get the generater value outside of the SQL if needed SQL as you do OR use a 'Returning' clause in my SQL (FB 2.5 and above).
Cheers
Rob
Glad I could help. I would use a TImage as you suggest.
For what its worth I avoid building SQLs as strings where possible as it avoids dealing with special characters etc. I would do it as
SQL.Clear;
SQL.Add('insert into PICS (pic_id, pic, comment, pic_type_id, target_id)');
SQL.Add('values (GEN_ID(GEN_PICS, 1), :pic, :comment, :pic_type_id, :target_id');
Prepare;
ParamByName('pic').LoadFromFile(picFile);
ParamByName('comment').AsString := 'No comment';
ParamByName('pic_type_id').AsInteger := 300;
ParamByName('target_id').AsInteger := mtrID;
Execute;ParamByName('pic').LoadFromFile(picFile);
ParamByName('comment').AsString := 'No comment';
ParamByName('pic_type_id').AsInteger := 300;
ParamByName('target_id').AsInteger := mtrID;
p.s. I would get the generater value outside of the SQL if needed SQL as you do OR use a 'Returning' clause in my SQL (FB 2.5 and above).
Cheers
Rob
On 6/10/2015 4:00 p.m., russell@... [IBObjects] wrote:
Thanks Rob and Massimo.It did not occur to me to use paramByName(...).loadFromFile(..). To load the DB from a file I used************// get picFile,use picID to locate the recordpicId := getGenValue('GEN_PICS');with dsqlRW dobeginsql.text := 'insert into PICS (pic_id,pic,comment,pic_type_id, target_id) values ('+#13+quotedStr(inttostr(picID))+',:anImage,'+'''No comment'', ''300'',+' +quotedStr(inttostr(mtrID))+')';ParamByName('anImage').LoadFromFile(picFile);prepare;execute;end;************
In my program users can select an image file using TOpenPictureDia log which supports more image formats than IBO TIB_IMAGE which supports only bmp, ico and Metafile. (I checked the first two and they load in a TIB_IMAGE control)
So I guess I'll use another control here not the TIB_IMAGE.Perhaps Delphi's TImage and the dataSOurce's OnChange event to load the blob image into a TBLOBStream then into the TImage.Picture?
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6140 / Virus Database: 4435/10764 - Release Date: 10/05/15