Android Question JRDC2 Client Help

luisro

Member
Licensed User
I already have the JRDC2 server connected to my database and to my application.

Now the truth is not how to read the results or where you could read them to assign them to labels or imageView. I would also like to know how to upload files in a specific image(BLOB).

I do not have the level to do it, i need your help.

DataBase: test.
Table: nombres
Camp: nombre,apellido
ip: 192.168.0.92
WampServer
 

Attachments

  • RemoteDatabaseConnector.zip
    45.4 KB · Views: 234
  • JRDC2.zip
    85.7 KB · Views: 234
  • img1.png
    img1.png
    88.8 KB · Views: 264

Erel

B4X founder
Staff member
Licensed User
Longtime User
There is no point in uploading the projects you downloaded from the forum.

If you are using B4A v7+ then use the latest version of RDC.

B4X:
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("insert_animal", Array(Name, req.FileToBytes(File.DirAssets, "somefile")))
Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
Wait For(j) JobDone(j As HttpJob)
If j.Success Then
   Log("Inserted successfully!")
End If
j.Release
 
Upvote 0

luisro

Member
Licensed User
I would like to see an example of how to fill a listview with (nombre) and (apellido) all the results of all the columns found.

Thanks for your help so I study how the code works and are less doubts than clarifying along the way.
 
Upvote 0

luisro

Member
Licensed User
B4X:
  Private reqManager As DBRequestManager

Sub Button1_Click
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "insert_animal"
    cmd.Parameters = Array("image1", reqManager.FileToBytes(File.DirAssets, "icon.png"))
    reqManager.ExecuteBatch(Array(cmd), Null)
End Sub

Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
    Else
        If Job.JobName = "DBRequest" Then               
Log("Inserted successfully!")
                Next
        End If
    End If
    Job.Release
End Sub


this is correct? or I have to add something to the DBRequestManager class?
 
Upvote 0

luisro

Member
Licensed User
The problem of loading data already solves it with the jobdone and dbresult and handlejob. The truth did not know how he knew how the code worked, but to see it and to see it and I only understand a little. See with a little clarity. I am now trying to upload an image uploaded from my files to a BLOB field. Here is my doubt now.
 
Upvote 0

luisro

Member
Licensed User
The license I had was a gift pitifully I do not have the possibility to acquire another, the situation in my country Venezuela is critical. thanks for your help.
 
Upvote 0

luisro

Member
Licensed User
B4X:
Sub button1_Click
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "select_animal"
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub

Sub Button2_Click  
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "insert_animal"
    cmd.Parameters = Array As Object("1","imagen", reqManager.FileToBytes(File.DirAssets, "icon.png"))
    reqManager.ExecuteBatch(Array(cmd), Null)
End Sub

B4X:
Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object)
    Dim ser As B4XSerializator
    Dim data() As Byte = ser.ConvertObjectToBytes(CreateMap("command": Command, "limit": Limit,  "version": VERSION))
    SendJob(data, Tag, "query2")
End Sub

Private Sub SendJob(Data() As Byte, Tag As Object, Method As String)
    Dim j As HttpJob
    j.Initialize("DBRequest", mTarget)
    j.Tag = Tag
    j.PostBytes(link & "?method=" & Method , Data)

Public Sub ExecuteBatch(ListOfCommands As List, Tag As Object)
    Dim ser As B4XSerializator
    ser.Tag = Tag
    ser.ConvertObjectToBytesAsync(CreateMap("commands": ListOfCommands,  "version": VERSION), "ser")
End Sub

B4X:
Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
    Else
        Dim result As DBResult = reqManager.HandleJob(Job)
           Select Job.JobName
          
            Case case1
          
            Case case2
            
            
            End Select
    End If
    Job.Release
End Sub

I can not find how to add jobs in a JobDone and a Case now this is what I am missing. How do i relate the ExecuteBatch and ExecuteQuery to a job name and then call them in the JobDone.
 
Upvote 0
Top