Im reading my language database and show it in B4Xtable. in this example the DB table "deutsch"
B4X:
B4XTable1.AddColumn("Code", B4XTable1.COLUMN_TYPE_TEXT)
ShowLanguage("deutsch")
Sub ShowLanguage(lang As String)
B4XTable1.AddColumn(lang, B4XTable1.COLUMN_TYPE_TEXT)
Dim Data As List
Data.Initialize
Dim rs As ResultSet = DB.GetConnection.ExecQuery("SELECT * FROM "&lang)
Do While rs.NextRow
Dim row(2) As Object
row(0) = rs.GetInt("code")
row(1) = rs.GetString("text")
Data.Add(row)
Loop
rs.Close
B4XTable1.SetData(Data)
End Sub
Now i want to display a third column from another language table to compare both languages. The code column is the same in every table.
Now i dont know how to add the second language, and later to swap both columns individualy with other languages. Any tips how to do that?
What is DB.GetConnection? If it is a ConnectionPool then you are leaking connections.
I'll assume that this is a local SQLite database.
B4X:
Dim CodesMap As B4XOrderedMap
CodesMap.Initialize
Dim rs As ResultSet = DB.GetConnection.ExecQuery("SELECT * FROM "&lang)
Do While rs.NextRow
Dim row(3) As Object
row(0) = rs.GetInt("code")
row(1) = rs.GetString("text")
Data.Add(row)
CodesMap.Put(row(0), row)
Loop
rs.Close
Dim rs As ResultSet = DB.GetConnection.ExecQuery("SELECT * FROM "& Lang2)
Do While rs.NextRow
Dim Code As Int = rs.GetInt("code")
Dim row() As Object = CodesMap.Get(Code)
row(2) = rs.GetString("text")
Loop
rs.Close