SQLPreparedStatementMBS.kTypeBlob giving TypeMismatchException with Pictures

I am getting a TypeMismatchException whilst inserting (or updating) a Picture into my CubeSQL database using SQLPreparedStatementMBS. If I remove the adding of the Picture BLOB, it inserts OK. So I have created a tiny app that lets you create an SQLite database instead and it shows the same symptoms.

What is the best way to INSERT or UPDATE a Picture with SQLDatabaseMBS if not using?:

tempSQLPreparedStatementMBS.BindType("Avatar", SQLPreparedStatementMBS.kTypeBlob) tempSQLPreparedStatementMBS.Bind("Avatar", LogoMBS)

I have a sample here if anyone wants to try it:
http://www.webappdevelopments.com/downloads/UPDATEPictureError.zip

This is the code that does the INSERT:

[code]Var tempSQL As String = “INSERT INTO Data(FirstName, LastName, Avatar) VALUES (:FirstName, :LastName, :Avatar)”
Var tempSQLPreparedStatementMBS As SQLPreparedStatementMBS
Var rs As RowSet

If Not db.isConnected Then
MessageBox “There was a problem connecting to the database”
Return
End If

tempSQLPreparedStatementMBS = db.Prepare(tempSQL)

tempSQLPreparedStatementMBS.BindType(“FirstName”, SQLPreparedStatementMBS.kTypeString)
tempSQLPreparedStatementMBS.Bind(“FirstName”, “Joe”)

tempSQLPreparedStatementMBS.BindType(“LastName”, SQLPreparedStatementMBS.kTypeString)
tempSQLPreparedStatementMBS.Bind(“LastName”, “Blogs”)

tempSQLPreparedStatementMBS.BindType(“Avatar”, SQLPreparedStatementMBS.kTypeBlob)
tempSQLPreparedStatementMBS.Bind(“Avatar”, LogoMBS)

Try
tempSQLPreparedStatementMBS.ExecuteSQLMT '<-- This gives a TypeMismatchException when the Picture is added
db.CommitTransaction

rs = db.SelectSQL(“SELECT COUNT(*) FROM DATA”)

Catch Error
MessageBox "Sorry, but there was an error: " + Error.Message '<-- Error: attempt to write a readonly database
Return
End Try

MessageBox "The User has been added for a total of: " + rs.ColumnAt(0).StringValue
[/code]

LogoMBS is a memoryblock? folderitem? string?

In my app I have been using a Picture, but LogoMBS was convenient for the example app. In my app, when I hover over it, it says LogoMBS returns a Picture.

If I change the statement to this, it still gives the same error:

Var tempPicture As Picture = LogoMBS tempSQLPreparedStatementMBS.BindType("Avatar", SQLPreparedStatementMBS.kTypeBlob) tempSQLPreparedStatementMBS.Bind("Avatar", tempPicture)

picture won’t work.
Please use LogoMBS.GetData with the desired format and pass the memory block you get.

Thank you, that works for the Desktop App Pictures from an ImageWell, but I cannot see an equivalent for a WebImageViewer:

 WebImageViewerAvatar.Picture.GetData(Picture.FormatPNG, Picture.QualityHigh)

How do I get the data from a WebImageViewer as a MemoryBlock ready for updating the database field?

A webPicture object?
Just check the data property on it.

Thank you @Christian Schmitz , that worked. I didn’t need to create a WebPicture in the end, just pass the Picture to a temporary variable and it works on the Web the same as the Desktop.

Var tempPicture As Picture = AvatarPicture.Picture CommonSQL.doPreparedArraysWAD(fieldNames, fieldTypes, fieldValues, "AvatarPicture", "BLOB", tempPicture.GetData(Picture.FormatPNG, Picture.QualityHigh))