How to add an image into blob field from imagewell in Mysql Db

Dear All,

I have put the following code in the save button of my project to add a image from imagewell into Blob field in Mysql. I get an parameter mismatch error. I could not resolve this. Can anyone please help me. Thank you.
///////////////Code in Action event of Save button//////////////////
Dim Sql as String
ssssterp.SQLExecute(“START”)
Sql = “INSERT INTO prod_mstr (BarCode,Image) VALUES (?,?)”

Dim Ps As PreparedSQLStatement = ssssterp.prepare(Sql)
Ps.BindType(0, MySQLPreparedStatement.MYSQL_TYPE_STRING)
ps.BindType(1, MySQLPreparedStatement.MYSQL_TYPE_BLOB)

Ps.SQLExecute(Barcode.Text,Imagewell2.image)

If ssssterp.error then
msgbox(ssssterp.errormessage)
return //why go further? You had an error.
End
ssssterp.SqlExecute(“Commit”)
MsgBox(“Record Saved Successfully”)
//////////////////////////////////////////////////////////////////////////////////////////

Regards,
Sriram.

You need to convert the image into a MemoryBlock. Use Imagewell2.image.GetData(). Check the documentation for the parameters to use in GetData.

Thanks Tim for your help. I wrote the following code with your help . There is no error and the record is saved but the image is not added. Can you please this code. I searched our blog and could not find this final step to make the code work.

// The below code is in the Action event of Save push button

//Saving entered record into prod_mstr table
Dim Sql as String
ssdb.SQLExecute(“START”)
Sql = “INSERT INTO prod_mstr (BarCode, Image) VALUES (?,?)”
Dim Ps As PreparedSQLStatement = ssssterp.prepare(Sql)
Ps.BindType(0, MySQLPreparedStatement.MYSQL_TYPE_STRING)
ps.BindType(1, MySQLPreparedStatement.MYSQL_TYPE_BLOB)

Dim vmb_image As MemoryBlock
If ImageWell2.Image <> Nil Then
// Get the image data
vmb_image = ImageWell2.Image.GetData(Picture.FormatJPEG, Picture.QualityHigh)
End If
ps.SQLExecute(Barcode.Text,vmb_image)
If ssdb.error then
msgbox(ssssterp.errormessage)
return //there is an error.
End
ssssterp.SqlExecute(“Commit”)
MsgBox(“Record Saved Successfully”)
Exit