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]