Using jRDC to get data from MySql server. The code below works in B4A. The keys are in the order of the fields in the SQL Select statement in jRDC. The record columns are in the same order as the keys.
However, in B4i the record columns are in some other order that makes no sense. I am even more baffled because I am using the exact same DBRequestManager.bas in both B4A and B4i.
Trying to make a generic way to copy select records from MySql to local SQLite on device.
However, in B4i the record columns are in some other order that makes no sense. I am even more baffled because I am using the exact same DBRequestManager.bas in both B4A and B4i.
Trying to make a generic way to copy select records from MySql to local SQLite on device.
B4X:
Private Sub InsertRDCRecords(TableName As String, Res As DBResult)
' Get Field Names --------------------------------------------------
Dim colArray(100) As String ' why do I have to put 100
Dim iCol As Int = -1
For Each col In Res.Columns.Keys
iCol = iCol + 1
colArray(iCol) = col
Log("col = " & colArray(iCol))
Next
' Insert Records --------------------------------------------------
Dim iList As List
For Each row() As Object In Res.Rows
iList.Initialize
Dim m As Map
m.Initialize
Dim iRow As Int = -1
For Each record As Object In row
iRow = iRow + 1
Log(colArray(iRow) & " = " & record)
m.Put(colArray(iRow),record)
Next
iList.Add(m)
DBUtils.InsertMaps(Main.SQL1,TableName,iList)
Next
End Sub