Go to Post You can never have enough figurative language. - Travis Hoffman [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 29-09-2012, 11:31
miki miki is offline
Registered User
no team
 
Join Date: Sep 2012
Location: USA
Posts: 2
miki is an unknown quantity at this point
PROBLEM with Retrieve image from MySql to Timage Using Delphi

Hello,

I have problem to retrieve image from MySql database to Timage using delphi.

I can load image in to TImage (using TOpenPictureDialog). I can save Picture From Timage into MySql database. But I cant retrieve and show image into TImage.

sometimes I can retrieve image , but show only first image from database. I want to scroll DBGrid and see how pictures are changing.

I use this code for load, save and retrieve picture.

-Load image
Quote:
var
sDir : string;
begin
OpenPictureDialog1.Execute;
sDir := OpenPictureDialog1.FileName;
Image1.Picture.LoadFromFile(sDir);
end;
-save image
Quote:
var
AStream : TMemoryStream;AStream := TMemoryStream.Create;
try
Image1.Picture.Graphic.SaveToStream(AStream);
AStream.Position := 0;
if ADODataSet1.Active then
begin
ADODataSet1.Edit;
TBlobField(ADODataSet1.FieldByName('MyField')).Loa dFromStream(AStream);
ADODataSet1.Post;
end;
finally
AStream.Free;
end;
-Retrieve image
Quote:
var
AStream : TMemoryStream;
begin
AStream := TMemoryStream.Create;
try
if ADODataSet1.Active then
begin
TBlobField(ADODataSet1.FieldByName('MyField')).Sav eToStream(AStream);
AStream.Position := 0;
Image1.Picture.Graphic.LoadFromStream(AStream);
end;
finally
AStream.Free;
end;
end;

Last edited by miki : 29-09-2012 at 11:33.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:39.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi