INSERT Problem

I’ve encountered a problem after I upgraded from XOJO 2018 to 2019 while inserting a blob into my SQLite database. I can’t do it without an error. My code is simple:

[code]Dim rec As New DatabaseRecord
rec.IntegerColumn(“id”) = Val(tbImageID.Text)
rec.Column(“name”) = tbImageName.Text
rec.BlobColumn(“pic”) = imageCanvas.Backdrop

mDB.InsertRecord(“images”, rec)

If mDB.Error Then MsgBox(mDB.ErrorMessage)

It worked just fine before I upgraded. I read in the documentation that PictureValue was deprecated and to use BlobValue instead, but with either I get errors I didn’t get before.

Using PictureValue:

Using BlobValue:

Now I’m wondering how to resolve it. I’m open to suggestions.

You can’t just replace picturevalue with blobcolumn. It looks like you need to use

rec.BlobColumn("photo") = photoCanvas.Backdrop.GetData(Picture.FormatPNG)

You can click on the UnsupportedFormatException in the Debugger to show more information about the exception. Perhaps the Message property will offer guidance.

Alternatively, using BlobColumn works but you have to send it the data, not a Picture. The example code on the doc page shows how:

rec.BlobColumn("pic") = imageCanvas.Backdrop.GetData(Picture.FormatPNG)

Lastly, if you’d want to use API 2.0, the code would be like this:

[code]Var row As New DatabaseRow

row.Column(“id”).IntegerValue =Integer.FromString( tbImageID.Value)
row.Column(“name”).StringValue = tbImageName.Value
row.BlobColumn(“pic”) = imageCanvas.Backdrop.ToData(Picture.Formats.PNG)

row.Column(“City”).StringValue = “Boston”
mDB.AddRow(“images”, row)
Catch error As DatabaseException
MessageBox("DB Error: " + error.Message)
End Try[/code]

Ok thanks guys. i’ll give it another try.

Thank you both for resolving my issue. I’m very pleased for the assistance!