insert an image into a database and also how to retrieve it

Please discuss general Delphi programming topics here.

insert an image into a database and also how to retrieve it

Postby claudiu_k » September 18th, 2009, 10:29 am

](*,)

Hi!

Please help me! I need to know how to insert an image into a database and also how to retrieve it back?
So, I have a table (PictureTable) whit one column named (Picture) and I need to insert, update and to access images.
On the program I have a table, a picture which I change how I wont and a button. When I click the button I need to insert the new image in table and when I click the table I need to get the image in the image component from the activated table row.

Thanks you!
claudiu_k
Member
Member
 
Posts: 1
Joined: September 18th, 2009, 10:25 am

Re: insert an image into a database and also how to retrieve it

Postby Kambiz » September 18th, 2009, 1:37 pm

Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: insert an image into a database and also how to retrieve it

Postby geowink » September 18th, 2009, 5:50 pm

I suggest putting the name of the graphic in the database. I put the base location in an INI file entry so that makes it changeable. That is, c:\MyPics\ goes in the INI and PictureName goes in the field. Then get the total location: GraphPath := IniLoc + PictureName + '.jpg';

Then...

if FileExists(GraphicPath) then
begin
Stream := TMemoryStream.Create;
Image := TJPEGImage.Create;
try
Image.LoadFromFile(GraphicPath);
Image.SaveToStream(Stream);
Stream.Position := 0;

Just a possibility.

George
George
geowink
Junior Member
Junior Member
 
Posts: 37
Joined: November 29th, 2005, 3:59 am
Location: La Grange, Illinois


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 7 guests

cron