update picture in database

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

if can_miniphoto(2).Backdrop <> NIL then
f = SpecialFolder.Temporary.Child( "Temp_Image.jpg" )
f.SaveAsPicture can_miniphoto(1).Backdrop
if can_miniphoto(2).Backdrop <> nil then 
  If bs <> NIL then
    imageData = bs.read( bs.length )
  End if
  If f.exists then
  End if
End if

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.


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:


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);

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

Thks Nicolas

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