Sub Class_Globals
Private Root As B4XView
Private SQL As SQL
Private Const Filename As String = "db1.db"
Private xui As XUI
Private B4XTable1 As B4XTable
End Sub
Public Sub Initialize
If File.Exists(xui.DefaultFolder, Filename) = False Then 'filename is database name
File.Copy(File.DirAssets, Filename, xui.DefaultFolder, Filename)
End If
SQL.Initialize(xui.DefaultFolder, Filename, False)
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")
B4XTable1.AddColumn("Student_Num", B4XTable1.COLUMN_TYPE_NUMBERS)
B4XTable1.AddColumn("Student_Name", B4XTable1.COLUMN_TYPE_TEXT)
Dim rs As ResultSet = SQL.ExecQuery("SELECT studnum, studname FROM student ")
Dim Data As List
Data.Initialize
Do While rs.NextRow
Dim r(rs.ColumnCount) As String
For j=0 To rs.ColumnCount -1
r(j) = rs.getstring(rs.GetColumnName(j))
Next
Data.Add(r)
Loop
rs.Close
B4XTable1.SetData(Data)
End Sub
Private Sub Button1_Click
B4XTable1.Clear
B4XTable1.AddColumn("Student_Num", B4XTable1.COLUMN_TYPE_NUMBERS)
B4XTable1.AddColumn("Student_Name", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Student_City", B4XTable1.COLUMN_TYPE_TEXT)
Dim rs As ResultSet = SQL.ExecQuery("SELECT * FROM student ")
Dim Data As List
Data.Initialize
Do While rs.NextRow
Dim r(rs.ColumnCount) As String
For j=0 To rs.ColumnCount -1
r(j) = rs.getstring(rs.GetColumnName(j))
Next
Data.Add(r)
Loop
rs.Close
B4XTable1.SetData(Data)
End Sub