I have a SQLite database table with a field named ‘Image’ defined as a BLOB
I have a WebImageView control on a WebPage.
I have a property on the oObject class named ‘Image’ defined as ‘picture’
When the oObject is instantiated the statement oObject.Image = pAvatar.picture is executed
I have generally used the Edit/Update classes in desktop app but since this web app may end up using a db other than SQLite, I thought it was time to change my ways. And yes, I will set it up as a prepared statement once I get it basically working.
When I compile the app I get the following error message on the Image statement. It is the ONLY error generated. So, how do I code this to update the image field?
sSQL = sSQL + "Gender = '" + oObject.Gender + "', "
sSQL = sSQL + "Image = " + oObject.Image + ", "
sSQL = sSQL + "ZipCode = '" + oObject.ZipCode + "', "
thanks guys, can always count on finding answers here…
I am also using SQL statement in some areas of my xojo application but never tried to include BLOB type. Maybe you can use PREPARED STATEMENT to avoid problems on column type.
I hope this help.
Stick with using the DatabaseRecord class and use RecordSet for Update/Edits to avoid unforeseen future issues with any irregular characters, etc. You need to set the datatype of the object (blob) being returned. Xojo itself doesn’t know what to do with the binary data that is returned. You can write a method to read the first few bytes of a binary blob to make an “auto-handler.” That is the basis of one of the new features coming up in our XDSAutoDatabase classes at . Generally, the first few bytes can tell you if the blob is an exe, zip, xojo project, raw text (if characters contained exist within a certain keycode range), png, gif, jpg, etc Open an image in a text editor, you’ll see the image type in the first few bytes…sometimes, like with Photoshop, the author, copyright, etc can also be embedded within the first set of bytes.
But for your case, you’ll want to invoke the data, and at the same time assign it a “Picture” super class type, so that you’ll be able to use it as you intend.
Try something along the lines of:
Dim Avatar as Picture
Avatar = RS.Field("TheImageColumnName").PictureValue
WebImageWell.Picture = Avatar
-or- the data that is returned for the blob…
Dim Avatar as Picture = Picture.FromData(“alloftheblobbinarydata”)
WebImageWell.Picture = Avatar[/code]
If you need any one-on-one help, PM me and I’ll be more than glad to get you up and running
I too use
PictureValue to store / restore images from/to