Android Question Using jRDC2 to Populate several labels

Kiumbe

Member
Hello,
Have been learning programming in B4A since last week and the progress and support is amazing, thank-you all for the help and support.
I have a query through jRDC that has returned a record with 6 columns and 2 rows. How do I insert row 2 entries on my labels on my activity?
Say I have:
lblName.text=
lblAge.text=
lblPhoneNo.text=
lblAccountNo.text=
lblAccType.text=
lblBalance.text=


All examples have come across illustrates populating data from a query to a listview.
Thanks in advance for your assistance.
 

Bladimir Silva Toro

Active Member
Licensed User
Hello @Kiumbe

If you want to show the values that your jRDC query returns, pay attention to whether it will return 1 or several values, if it is only 1 value you can do it with the labels or textfields objects, if there are several values you must do it with the B4XTable or ListView object.

This is the code to return 1 single value which is shown in the labels
B4X:
Sub CaptureVal(Val As Int) As ResumableSub
        Dim req As DBRequestManager = CreateRequest
        Dim cmd As DBCommand = CreateCommand("ultimafact_tblfacturaenc,Array(Val))
        'req.ExeucteQuery returns a HttpJob. The returned HttpJob is used as the sender filter.
        Wait For (req.ExecuteQuery(cmd, 0, Val)) JobDone(j As HttpJob)
        If j.Success Then
            req.HandleJobAsync(j, "req")
            Wait For (req) req_Result(result As DBResult)
            If j.JobName = "DBRequest" Then
                Dim result As DBResult = req.HandleJob(j)
                For Each records() As Object In result.Rows
                    lblname.text= records(result.Columns.Get("Name"))
                    lblage.text= records(result.Columns.Get("Age"))
                    blPhoneNo.text= records(result.Columns.Get("Phone"))
                    lblAccountNo.text= records(result.Columns.Get("Account"))
                    lblAccType.text= records(result.Columns.Get("AccType"))
                    lblBalance.text= records(result.Columns.Get("Balance"))
                Next
            End If
        End If
    Dim res As DBResult = Null
    Return res
End Sub

I hope I have been helpful.
 
Upvote 0

Kiumbe

Member
I hope I have been helpful.
Very helpful, that exactly what I was looking for, now am good. Thanks a lot Silva. I dont know if its okay if I enquire from you something a little different, I want to have a thourough understanding of resumable subs in B4A, I have read the guide severally but am not getting the clarity I need. Can you giv me an example of a function that works out some arithmetic say calculate age of a person given age and return the result to the calling sub. Thanks again
 
Upvote 0
Top