Android Question RDC Question

lanadmin

Member
Licensed User
Longtime User
So I began using RDC yesterday on a project to connect to SQL server. I have everything set up and working great but I have a question. How would I go about taking the data returned in the RDC example and displaying that in a table or list view? Is there a tutorial around for something like this?
 

lanadmin

Member
Licensed User
Longtime User
Im basically just using Erel's example right now to try and figure out how to display the data. Can someone point me in the right direction as to how to take the data returned here and display it in a listview?

B4X:
Sub Process_Globals
    Dim reqManager As DBRequestManager
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        reqManager.Initialize(Me, "http://10.28.96.18:17178")
    End If
End Sub

Sub Activity_Click
    GetAnimal("1")
End Sub

Sub GetAnimal(Name As String)
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "select_user"
    cmd.Parameters = Array As Object(Name)
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub

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

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I wouldn't use a ListView to show a table. Use TableView instead: http://www.b4x.com/android/forum/threads/class-tableview-supports-tables-of-any-size.19254/#content

result.Rows holds a list of arrays of objects. Each item in the list represents a row.
TableView works with arrays of strings, so you will need to convert the array of objects to array of strings:
B4X:
For Each Row() As Object In result.Rows
 Dim RowS(Row.Length) As String
 For i = 0 To Row.Length - 1
   RowS(i) = Row(i)
 Next
 Table1.AddRow(RowS)
Next
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…