Reg How To Insert Image File Into MySQL Blob Filed In Delphi

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
varathasiva
Fresh Boarder
Fresh Boarder
Posts: 17
Joined: 28.05.2007, 14:31

Reg How To Insert Image File Into MySQL Blob Filed In Delphi

Post by varathasiva »

Dear All,
Please advice me
How To Insert Image File Into MySQL Blob Filed In Delphi 7 Coding.
I am saving image into PostgreSQL bytea field through this coding.Its work fine tablenamne.FieldByName('byteafiled') .LoadFromFile('c:\temp.jpg');
When i use this coding MySQL blob means.I am getting Error
Einvalid Graphic With Message Bitmap Image Is Invalid like this.
For database connection and query i am using Zeos Access Component.Please help me.How to solve this problem.Advance thanks to all.
Thanks & Regards
Siva
manz
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.06.2008, 03:58
Location: Cilegon
Contact:

Post by manz »

Hi varathasiva ..

In MySQL you may used LONGBLOB instead BLOB data type.

for the saving image you may try this :

Code: Select all

var
  J: TJPEGImage;
begin
  J := TJPEGImage.Create;
  J.LoadFromFile('C:\Manz\Projects\Web\hrms\public_html\images\photo\1357a.jpg');
  zTable2.Active := true;
  ztable2.Append;
  ztable2.FieldByName('foto').Assign(J);
  ztable2.Post;
  FreeAndNil(J);
end;
Hopefully work, but you may not use at Delphi 2009 with Zeos 7 beta version, because this would be JPEG Error maybe Bad Format.

:D

Thanks
Man'z
varathasiva
Fresh Boarder
Fresh Boarder
Posts: 17
Joined: 28.05.2007, 14:31

Post by varathasiva »

Dear Man'z,
Thanks for your quick repy.
I am using same code wht u sent to me.

var
J: TJPEGImage;
begin
if OpenPictureDialog1.Execute then
begin
J.LoadFromFile('c:\temp\ok1.jpg');
student.FieldByName('stu_photo').Assign(J);
student.Post;
FreeAndNil(J);
end;
end;
When i complier comes this line
J.LoadFromFile('c:\temp\ok1.jpg');
Its showing Access Violation Error.Please help me.How to solve this problem.
Im waiting for ur reply.Advance Thanks to u.
Thanks & Regards
Varathasiva
manz
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.06.2008, 03:58
Location: Cilegon
Contact:

Post by manz »

Dear Varathasiva,

you miss one line of it :

J := TJPEGImage.Create;

before you can do J.LoadFromFile(....

Thanks
Man'z
Post Reply