Forum > Databases

DBImage: how to use?

<< < (2/7) > >>

BigChimp:
Edit: posted before reading previous message...
Decided I was probably too optimistic about the copy/paste thing being possible, so added a button that puts a file into the dbimage picture and tries to save the result.

Get error message
An error occurred while applying the updates in a record
DBConnection : PrepareStatement
attempted update of read-only column
and indeed the image is not saved.

Don't tell me I have to manually deal with CreateBlobStream etc ;)
(Argh, I hate GUI controls... but you can't live without them ;) )

New zip:
http://ubuntuone.com/0KmpZX0xFF436381Ymib9w

Up to date source code repo without .fdb though:
https://bitbucket.org/reiniero/fpc_laz_patch_playground/src
sqldbtutorialimage

BigChimp:
(Posted previous post before reading this one)

--- Quote from: taazz on January 10, 2014, 03:12:32 pm ---Your blob stream has no bmp in front as it should or I couldn't see it from IBExpert light.

--- End quote ---
Ah, now I know what you mean: you're talking about the existing blobs/images in my initial upload. Yes, those are regular jpg files, and it's no problem that they don't display etc.
I was testing with the records at the end where the blobs are empty/null.

Sorry about that.

taazz:
do the following

1) drop a TOpenPictureDialog on your form.
2) doubleclick on the onclick of the DBImage1 and paste this code.

--- Code: ---  if OpenPictureDialog1.Execute then begin
    DBImage1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
  end;

--- End code ---
3)run your application
4) select any record you like and press the edit button on the dbnavigator.
5) click on your image and select any image you like.
6) press the post button on the dbnavigator.

change records in the grid and see if re visiting the specific record it shows the new image.
There is a small chance that you must use persistent fields namely after you create the fields in the designer select the photo field and change the blobtype to ftgraphic and try again. Are you sure that the subtype 0 on the firebird blob is for binary data and not for text? I ask because the default setting comes back as ftwidestring instead of ftgraphic and makes to want to check the subtype meaning again.

BigChimp:
Thanks.

Blob subtype 0 is binary data
http://www.firebirdfaq.org/faq165/

Tried your suggestion. Edit/post works, scrolling back & forth too (including showing the image), but when calling applyupdates I still get the update readonly field problem.

Updated repository with new code.

taazz:
I guess the problem you have is that the applyupdate tries to update the blob qith an update sql command instead of using the blobostreams to post the data and that seems is not supported from firebird. Please keep in mind that this is speculation at this point and I haven't checked anything.

Late me say at this point that I hate the buffered editing implementation of sqlDB and it is the main reason that I am looking at ZEOS as an alternative.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version