Save picture in db sqlite

Salve is just that I use xojo
Lately I’ve found a little difficulty I can not save or update an image attached to the db

1 - I created the field as blob

2 run this code to save him but not fuziona

'Opening the database

Dim dbFile As FolderItem
Dim db As New SQLiteDatabase
dbr dim as recordset
dbFile = GetFolderItem (“C: \ Users \ Rico Vast \ Documents \ project-xojo / database.sqlite”)
db.DatabaseFile = dbFile

Then if db.connect
// Proceed with database operations here …
'MsgBox (“Data base successfully opened”)
'Queries generic creating the recordset

Dim p As Picture = Canvas1.Backdrop
Dim mb As MemoryBlock = p.GetData (Picture.FormatJPEG, Picture.QualityMax)
Dim s As String = mb
db.SQLexecute ("INSERT INTO test (code, name, first name, photo) VALUES ('" + codicetxt.text + "', '" + cognometxt.text + "', '" + nometxt.text + "', '" + s + "')")
db.SQLExecute ("COMMIT")

Else
MsgBox (“Do not be opened because the Db. Error:” + db.ErrorMessage)
End If

The same thing happens in the process of renovation

Dim dbFile As FolderItem
Dim db As New SQLiteDatabase
dim selected as string
dbFile = GetFolderItem (“C: \ Users \ Rico Vast \ Documents \ project-xojo / database.sqlite”)
db.DatabaseFile = dbFile

selected = Listbox1.Cell (ListBox1.Listindex, 0) .ToText

Then if db.connect
// Proceed with database operations here …
'MsgBox (“Data base successfully opened”)
'Queries generic creating the recordset

As picture dim p = Canvas1.Backdrop
Dim mb As MemoryBlock = p.GetData (Picture.FormatJPEG, Picture.QualityMax)
Dim s As String = mb
   

db.SQLExecute ("BEGIN TRANSACTION")
db.SQLexecute ("update test in September last name = '" + cognometxt.text + "'" + "name = '" + nometxt.text + "'" + "photo =" + s + "where code = '" + selected + " '")
db.commit


If db.Error Then MsgBox (db.ErrorMessage)

Else
MsgBox (“Do not be opened because the Db. Error:” + db.ErrorMessage)
End If

Definitely wrong to do something

Thanks for your help

What happens?

dbFile = GetFolderItem (“C: \ Users \ Rico Vast \ Documents \ project-xojo / database.sqlite”)
This is not a valid path to the file: either this file does not exist or this is not your actual code.

[quote]Then if db.connect[/quote] … will generate a syntax error

[quote]As picture dim p = Canvas1.Backdrop
[/quote] will also generate a syntax error

This cannot be the code you are trying to run?

After the dbFile = statement, and before the connect, you should check if the file actually exists.

And another thing, you have

[code]db.SQLExecute (“BEGIN TRANSACTION”)
db.SQLexecute (“update test in September last name = '” + cognometxt.text + “’” + “name = '” + nometxt.text + “’” + “photo =” + s + “where code = '” + selected + " '")
db.commit

If db.Error Then MsgBox (db.ErrorMessage)[/code]
You should check for the db.error BEFORE the commit since if an error did occur in the SQLExecute you probably need to rollback the transaction. Plus, the way you have it, the db.Error being checked is from the commit, not the SQLExecute.