B4J Question jRDC2: Querying the DataBase...

Cableguy

Expert
Licensed User
Longtime User
Hi guys,

So, now that I got my jRDC server running, I started "messing" around with my testing DB...
I am now able to insert data into my data base...
But I can't figure out how to retrieve data from that same table...

Using Erel's examples, I am able to use the PrintTable(result) which will print the Column name and the Data that collumn contains...

I have tried a similar approach to the one used in the PrintTable sub, but I'm getting nowhere!

Can someone help?

I want to fill a listview with the data from a specific column...

[EDIT]

I GOT IT!

I just took the PrintTable sub and copy/paste it to my ReqManager_Result sub, and started stripping it from what I didn't need...
So in the end....

B4X:
    For Each row() As Object In result.Rows

        For Each record As Object In row
            ListView1.Items.Add(record)
            Log(record)
        Next
    Next
 
Last edited:

Harris

Expert
Licensed User
Longtime User
Have a look at this code:

It is from this post you started...

https://www.b4x.com/android/forum/threads/b4j-web-server-rdc-vs-php.74081/#post-470427


B4X:
Public Sub GetRecsTable(Table As DBResult) As Map
    Dim Mainmap As Map
    Dim Submap, Colmap As Map
    Mainmap.Initialize
    Submap.Initialize
    Colmap.Initialize
  
    Dim i,j As Int
    i = 0
    j = 0
  
    For Each col In Table.Columns.Keys
           Colmap.Put(i, col)
          i = i + 1      
    Next
    'Log(" Column map: "&Colmap)
  
    For Each row() As Object In Table.Rows
        i = 0
        j = j + 1
        Submap.Initialize
        For Each record As Object In row
            Dim r As String
            r = record
            r = r.Replace("'"," ")
            Submap.Put(Colmap.Get(i),r)
           i = i + 1
        Next
        Mainmap.Put(j, Submap)
    Next
    'Log("Mainmap 2")
  
    For i = 0 To Mainmap.Size -1
        Dim m As Map
        m.Initialize
        m = Mainmap.GetValueAt(i)
    Next
    Return Mainmap
  
End Sub
 
Upvote 0
Top