Hi there,
I’m trying to send a local SQLite DB from a iOS device into a MySQL server and the store it on a DeskTop for ‘Rescue Situations’, but I don’t get a valid SQLIte file. Valentina Reports will not open den file s I guess some data is gone missing in the process.
FileSize is all equal: [iOS SQLite File] = [MySQL BLOB] = [Saved DeskTop File]
Can you see what I’m doing wrong?
First I Read the SQLite file from my iPhone and send it via HTTP in JSON format to my WebService
Var ReadStream As BinaryStream = BinaryStream.Open(dbFile, BinaryStream.LockModes.Read )
ReadStream.LittleEndian = True
Var hashMB As New Xojo.Core.MemoryBlock(ReadStream.Read(ReadStream.Length))
fSize = ReadStream.Length
ReadStream.Close
Var joiner() As Text
For i As Integer = 0 To hashMB.Size - 1
Var b As UInt8 = hashMB.UInt8Value(i)
joiner.AddRow(b.ToHex(2))
Next
HexDB = Text.Join(joiner, “”)
After that my WebService stores the DecodeHex string directly in a MySQL LONGBlob field
Try
Var mbHex As MemoryBlock = DecodeHex(jsonUnPacked.Lookup(“DataBlob”, “”))
Var mb As MemoryBlock
mb = mbHex
Var UserID As Integer = jsonUnPacked.Lookup(“UserID”, 0)
Var UserName As String = jsonUnPacked.Lookup(“UserName”, “”)
Var CompanyName As String = jsonUnPacked.Lookup(“CompanyName”, “”)
Var fSize As Integer = jsonUnPacked.Lookup(“FileSize”, “”)
Var DeviceID As String = jsonUnPacked.Lookup(“DeviceID”, “”)
If dbIsPresent Then
Var InsertSQL As String = “INSERT INTO GRADUS.DEVICEDATA ( UserID, UserName, CompanyName, DataType, DataSize, DeviceID, SQLiteDB ) VALUES ( ?, ?, ?, ?, ?, ?, ?) ;”
myDB.ExecuteSQL(InsertSQL, UserID, UserName, CompanyName, “SQLITE”, fSize, DeviceID, mb )
End If
Catch err As JSONException
End Try
And lastly my Adm Program read the MySQL Blob and stores it in a file:
If rs.Column(“SQLiteDB”).Value <>Nil Then
Var WriteFile As FolderItem = GetSaveFolderItem("", fn)
If writeFile <> Nil Then
Var writeStream As BinaryStream = BinaryStream.Create(writeFile, True)
writeStream.LittleEndian = True
writeStream.Write(rs.Column("SQLiteDB").Value)
writeStream.Close
End If