update picture in database

Hello,
New on xojo, I have a big problem , I searched in the old forums without really having found a solution
I have a database, and I want to record pictures, and they are edited in canvas , everything works well.
But when I want to uptdate a picture and replace it with another one, it does not work, the recording has no been updated
i have use the string value method( field as blob) ,i dont understand what is wrong ?
Thks very much for your help
The code below to update ;

[code]rs=App.mabasecra.SQLSelect (“SELECT * FROM TB_PIC WHERE madtepic= '”+(app.verifdteedit)+"’")
if rs.RecordCount<>0 then
rs.edit

if can_miniphoto(2).Backdrop <> NIL then
f = SpecialFolder.Temporary.Child( "Temp_Image.jpg" )
f.SaveAsPicture can_miniphoto(1).Backdrop
bs=f.OpenAsBinaryFile(false)
if can_miniphoto(2).Backdrop <> nil then 
  If bs <> NIL then
    imageData = bs.read( bs.length )
    bs.close
    rs.Field("pic2min").stringValue=imageData
  End if
  If f.exists then
    f.delete
  End if
End if
      
rs.Update
rs.Close
app.mabasecra.Commit

end if[/code]

Edit (Paul): Updated to use code formatting tags. See Post Formatting Tips.

Perhaps using StringValue is be the problem? The docs say that it converts to UTF8 and for binary data you should just use Value.

http://documentation.xojo.com/index.php/DatabaseField.Value

Or you could use PictureValue: http://documentation.xojo.com/index.php/DatabaseField.PictureValue

There is an example included with Xojo that might also be helpful for you:

Examples/Database/DatabasePictureTest

I am still thinking that pictures should not be stored in the database but in a separate folder; Only the path to the picture should be stored in the database. Unless they are only small thumbnails. Some pictures like maps are huge (60 meg or more);
jjc

Thks for your answers , Paul and Jean Jacques
i m going to check the docs , i use a old version on “realbasic” so i hope is it possible to solve my problem .
in my program, pictures are not important size

Isn’t that’s why there is a Blob ?

to save the image
1- save your image to your local disk
2- read the image and convert it to encodebase64 string ()
3- save that LARGE string to the database as usual

to read the image
1- get the LARGE string from database
2- use decodebase64 to get the original image

here a few links
https://forum.xojo.com/32159-converting-and-saving-a-base64-image-sent-by-an-html-post/0
https://forum.xojo.com/32652-guardar-imagen-en-base-de-datos-sqlite/0#p267510

Thks Nicolas

I always save little pictures as HEX, SQL will do that for you using X

http://www.aprendexojo.com/2016/07/bases-de-datos-guardar-y-recuperar-imagenes/