Subject RE: [firebird-support] Sample Delphi code?
Author Graeme Edwards
I use the procedure below called like this



SavePicturetoDataBase(Image1.Picture,FIBPhotoQuery,'Photo','ImageType');



This assumes that the image is stored in an image component on a form after
being loaded from file or whatever.

This was taken from a snippet I found on the internet somewhere. It assumes
that you have opened a query using an

FIBDataset component which contains the blob field required. The other field
(imagetype) is for the programmer's convenience to let you

know what kind of image is stored in there.



Not sure if the commitretaining is required because I commit the transaction
outside of the procedure after having set

other fields like ID fields.





procedure SavePicturetoDataBase(Pic:TPicture;var
Qry:TpFIBDataSet;ImageName:String;ImageTypeName:String);

var TheStream:TMemoryStream;



begin

if not (Qry.State in [dsInsert,dsEdit]) then

Qry.Edit;

if (Pic.Graphic<>nil) then

begin



if (Pic.Graphic is TBitMap) then

Qry.FieldByName(ImageTypeName).AsInteger:=1

else

if (Pic.Graphic is TIcon) then

Qry.FieldByName(ImageTypeName).AsInteger:=2

else

if (Pic.Graphic is TMetaFile) then

Qry.FieldByName(ImageTypeName).AsInteger:=3

else

if (Pic.Graphic is TJPEGImage) then

Qry.FieldByName(ImageTypeName).AsInteger:=4;

TheStream:=TMemoryStream.Create;

try

Pic.Graphic.SaveToStream(TheStream);

TheStream.Seek(0,0);

TGraphicField(Qry.FieldbyName(Imagename)).Clear;

TGraphicField(Qry.FieldbyName(Imagename)).LoadFromStream(TheStream);



finally

TheStream.Free;

end;

end

else

begin



Qry.FieldByName(ImageTypeName).AsInteger:=0;

Qry.FieldByName(ImageName).Clear;

end;

qry.Post;

qry.Transaction.CommitRetaining;



end;



Graeme Edwards



_____

From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Myles Wakeham
Sent: Tuesday, 8 November 2005 12:26 AM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Sample Delphi code?



I have to store some images in a Delphi 7 application I'm designing, using
FIBPlus, and was wondering if anyone could point me in the right direction
for some example code on handling the storing of images from Delphi into
BLOBs in Firebird?

All help greatly appreciated.

Thanks
Myles

===========================
Myles Wakeham
Director of Engineering
Tech Solutions Inc.
Scottsdale, Arizona USA
Phone (480) 451-7440
Web: www.techsol.org



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://firebird.sourceforge.net and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !

Also search the knowledgebases at http://www.ibphoenix.com

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





SPONSORED LINKS


Technical
<http://groups.yahoo.com/gads?t=ms&k=Technical+support&w1=Technical+support&
w2=Compaq+computer+technical+support&w3=Compaq+technical+support&w4=Microsof
t+technical+support&w5=Technical+support+services&w6=Hp+technical+support&c=
6&s=183&.sig=8H7TxM4FCSYG2byN8Y-4BA> support

Compaq
<http://groups.yahoo.com/gads?t=ms&k=Compaq+computer+technical+support&w1=Te
chnical+support&w2=Compaq+computer+technical+support&w3=Compaq+technical+sup
port&w4=Microsoft+technical+support&w5=Technical+support+services&w6=Hp+tech
nical+support&c=6&s=183&.sig=G_FHqvMh_zcRobsWUfRzNw> computer technical
support

Compaq
<http://groups.yahoo.com/gads?t=ms&k=Compaq+technical+support&w1=Technical+s
upport&w2=Compaq+computer+technical+support&w3=Compaq+technical+support&w4=M
icrosoft+technical+support&w5=Technical+support+services&w6=Hp+technical+sup
port&c=6&s=183&.sig=ehV9KPhK5RjxGDlSg_Wrng> technical support


Microsoft
<http://groups.yahoo.com/gads?t=ms&k=Microsoft+technical+support&w1=Technica
l+support&w2=Compaq+computer+technical+support&w3=Compaq+technical+support&w
4=Microsoft+technical+support&w5=Technical+support+services&w6=Hp+technical+
support&c=6&s=183&.sig=STx8RbOy-goribvMDBgPEg> technical support

Technical
<http://groups.yahoo.com/gads?t=ms&k=Technical+support+services&w1=Technical
+support&w2=Compaq+computer+technical+support&w3=Compaq+technical+support&w4
=Microsoft+technical+support&w5=Technical+support+services&w6=Hp+technical+s
upport&c=6&s=183&.sig=Jbs5N4x6nvtDU9lkaJlJIQ> support services

Hp
<http://groups.yahoo.com/gads?t=ms&k=Hp+technical+support&w1=Technical+suppo
rt&w2=Compaq+computer+technical+support&w3=Compaq+technical+support&w4=Micro
soft+technical+support&w5=Technical+support+services&w6=Hp+technical+support
&c=6&s=183&.sig=viLeXtjcBioNpdr7NdTOvw> technical support



_____

YAHOO! GROUPS LINKS



* Visit your group "firebird-support
<http://groups.yahoo.com/group/firebird-support> " on the web.

* To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com
<mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>

* Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/> Terms of Service.



_____



[Non-text portions of this message have been removed]