Blah Blah Blob

jflaplante

Member
Licensed User
Longtime User
After a 3 months break from Basic4Android to attend my maple farm during maple season I'm back on the saddle with my project...

I've been successfully transferring large amount of data from an MySQL server to SQLite true basic4android and now is the time to return some data to the MySQL server.

My current project is an invoicing system which involves detail lines and header records.

I'm using the DBUtils.ExecuteJSON method as described in the DBUtils tutorial and it is working great for my detail line records.

My problem is with my header records which contain a client signature field stored as a blob. I first tried declaring the field as 'DBUtils.DB_BLOB' (since that type is available in the DBUtils) in the JSONGenerator init but I get an error saying 'invalid type: BLOB'. I guess I was hoping that it would magically be converted to base64 and included in the JSON string. Presently, the JSON string is still being created but the signature field is completely ignored.

Is there a way to simply convert the blob value and still use the ExecuteJSON method?

Thanks for any help.

JF.
 

jflaplante

Member
Licensed User
Longtime User
Thanks Erel for your reply,

I want to keep the blob format as it would seem that most example and tutorials I have seen about signature capture use the blob format.

As far as modifying the dbutils sub, would it be as simple as adding a case (line 237) in the select specifying the blob and convert it right there in base64? That seems too easy to be true! But if it is, it would be a great suggestion for dbutils2!

Thanks.

JF.
 
Upvote 0

jflaplante

Member
Licensed User
Longtime User
That was easy...

I consistently underestimate how easy it is to do stuff in B4A but you always give me the little push to do it...

I just added the following lines to the DBUtils ExecuteJSON sub (line 237):

B4X:
'Added JF Laplante 2013-05-10
Case DB_BLOB
Dim su As StringUtils
m.Put(cur.GetColumnName(i), su.EncodeBase64(cur.GetBlob2(i)))

And it seems to do the trick nicely. I haven't played with the data on the server yet but it does make its way there and is being recorded in the database in text. I'll play with it later.

Thanks again Erel.

JF.
 
Last edited:
Upvote 0
Top