mysql: insert into tablename pixfield=

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
crownfield
Posts: 5
Joined: Sun 11 Oct 2009 01:07

mysql: insert into tablename pixfield=

Post by crownfield » Thu 07 Oct 2010 22:02

mysql.sql.text:= ' insert into tablename set pixfield= ' + thepicture ???

where thepicture is from some vcl component, like Image1.picture?

how, in MYSQL, do I insert an image from a vcl into the table?

AndreyZ

Post by AndreyZ » Fri 08 Oct 2010 13:07

Hello,

You can use the following code:

Code: Select all

  Image.Picture.Bitmap.SaveToStream(ms); // where ms is TMemoryStream
  MyQuery.SQL.Text := 'insert into your_table(img) values(:img)';
  MyQuery.ParamByName('img').LoadFromStream(ms, ftBlob);
  MyQuery.Execute;

Post Reply