Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private pgSQL As SQL
Private TableViewHD As TableView
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
TableViewHD.SetColumns(Array As String("prod_line_id", "prod_line", "prod_line_desc"))
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
'xui.MsgboxAsync("Hello world!", "B4X")
Try
Dim connectionString As String = "jdbc:postgresql://localhost:5432/my_hd?user=postgres&password=Demo1234"
pgSQL.Initialize("org.postgresql.Driver", connectionString)
'Log("Connection successful!")
Dim rs As ResultSet = pgSQL.ExecQuery("SELECT * FROM product_line")
Do While rs.NextRow
Dim values(rs.ColumnCount) As Object
For i = 0 To rs.ColumnCount - 1
values(i) = rs.GetString2(i)
Next
TableViewHD.Items.Add(values)
Loop
rs.Close
pgSQL.Close
Catch
Log("Error: " & LastException.Message)
End Try
pgSQL.Close
End Sub