Android Question SQLite BLOB type to MSSQL Image or Varbinary(MAX)

Aries Abedes

Member
Licensed User
Hi,

I am trying to upload a BLOB data from SQLite db to MSSQL db using this code

B4X:
Sub btnUpload_Click
    UploadPOD
End Sub

Sub UploadPOD
   
    Dim Cur As Cursor
    'Cur = Starter.SQl1.ExecQuery2("SELECT PODID, RECEIVEDBY, RECEIVEDDATE, SIGNATURE FROM tblpoddetails WHERE RECEIVEDDATE IS NOT NULL "  , Array As String())
    Cur = Starter.SQl1.ExecQuery("SELECT PODID, RECEIVEDBY, RECEIVEDDATE, SIGNATURE FROM tblpoddetails WHERE RECEIVEDDATE IS NOT NULL")
    For i = 0 To Cur.RowCount - 1
        Cur.Position = i
        PodID = Cur.GetInt("PODID")
        ReceivedDate = Cur.GetString("RECEIVEDDATE")
        ReceivedBy = Cur.GetString("RECEIVEDBY")
        Signature  = Cur.GetBlob("SIGNATURE")
   
'        If Cur.GetBlob("SIGNATURE") <> Null Then
'            Dim Buffer() As Byte 
'            Buffer = Cur.GetBlob("SIGNATURE")
'            Dim InputStream1 As InputStream
'            InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
'            bmp.Initialize2(InputStream1)
'            InputStream1.Close
'            Try
'                imgSignature.Bitmap = bmp
'            Catch
'                Log(LastException)
'            End Try
'        End If
        SpForUpload
    Next
   
   
End Sub

Sub SpForUpload
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "upload_pod"
    cmd.Parameters = Array As Object(PodID, ReceivedDate, ReceivedBy, Signature )
    'cmd.Parameters = Array As Object(PodID, ReceivedDate, ReceivedBy, reqManager.ImageToBytes(bmp) )
    reqManager.ExecuteCommand(cmd, "UploadPOD")
End Sub

'-----------------------------------------------------------------------------------------------------
'|JOB DONE - FOR ASYNC CALL - UI STILL RESPOND WHILE PROCESSING SQL REQUEST   |
'-----------------------------------------------------------------------------------------------------
Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
    Else
        If Job.JobName = "DBRequest" Then
            reqManager.HandleJobAsync(Job, "ReqManager")
            'Dim result As DBResult = reqManager.HandleJob(Job)
        End If
    End If
    Job.Release
End Sub

Sub ReqManager_Result(result As DBResult)
       
    '------------------------------------
    '|UPLOAD RESULT                   |
    '------------------------------------
    #Region LoadPodList Result
    If result.Tag = "UploadPOD" Then 'query tag
        Log(result)
    End If
    #End Region 
End Sub

The RECEIVEDBY AND RECEIVEDDATE are pushed to the server but for the SIGNATURE i got these logs

B4X:
Logger connected to:  SKK chronos_ace
--------- beginning of main
** Service (starter) Destroy **
** Activity (areceivedpod) Pause, UserClosed = true **
--------- beginning of system
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (alogin) Create, isFirst = true **
** Activity (alogin) Resume **
19
** Activity (alogin) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (areceivedpod) Create, isFirst = true **
** Activity (areceivedpod) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
Class not found: b4j.example.main$_dbresult, trying: com.emeraldheadway.podreleasing.main$_dbresult
[Columns=(MyMap) {AffectedRows (N/A)=0}, IsInitialized=true, Rows=(ArrayList) [[Ljava.lang.Object;@cf36d3a]
, Tag=UploadPOD]
[Columns=(MyMap) {AffectedRows (N/A)=0}, IsInitialized=true, Rows=(ArrayList) [[Ljava.lang.Object;@3c95deb]
, Tag=UploadPOD]

Is there an issue when coverting this object? I even tried to convert it back to an image file and use the reqManager.ImageToBytes(bmp) but the same log i get.

Thank you.
 

Aries Abedes

Member
Licensed User
I'am sorry...It was with my stored procedure. I thought it was the {AffectedRows (N/A)=0} is the hint that is why may signature column in mssql is not populated.

Thank you.
 
Upvote 0
Top