Page 1 of 1

How to save an image as binary ?

Posted: Tue 24 Apr 2007 06:30
by haci
I would like to save an image as binary, i tried but it doesn't work! How can i do that ? Thank you.

Posted: Tue 24 Apr 2007 08:51
by Jackson
You can use the following construction to insert an image in the table.

Code: Select all

...
var
  BlobField: TBlobField;
begin
  MSQuery1.Insert;
  BlobField := MSQuery1.FieldByName('Picture') as TBlobField;
 
  BlobField.LoadFromFile('D:\Image.bmp');
  MSQuery1.Post;
end;
In this example, the "Picture" field is has the IMAGE data type.

Thank you...

Posted: Thu 26 Apr 2007 14:32
by haci
Thank you.

adding images to blobfield

Posted: Wed 08 Sep 2010 14:30
by Wallygator
This code works with the insert

Code: Select all

  
 MSQuery1.insert;
  BlobField := MSQuery1.FieldByName('Picture') as TBlobField;
  if getpic.Execute then
  BlobField.LoadFromFile(getpic.filename);
  MSQuery1.Post;
But what if i want to edit and exsisting record

Code: Select all

   MSQuery1.edit;
  BlobField := MSQuery1.FieldByName('Picture') as TBlobField;
  if getpic.Execute then
  BlobField.LoadFromFile(getpic.filename);
  MSQuery1.Post;
I get an EMSError "incorrect syntax near the keyword 'group'

WHY ???
Thanks

Posted: Thu 09 Sep 2010 09:15
by AndreyZ
Hello,

I could not reproduce the problem. Please, specify the SQL code that you are using in the MSQuery1.SQL and MSQuery1.SQLUpdate properties, and the exact place of the error appearance.
Note that the text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.