sto provando a caricare i dati di un DB su una tabella, ecco il risultato in allegato, cosa sbaglio, grazie.
questo il codice:
questo il codice:
B4X:
Sub Process_Globals
Private xui As XUI
Private fx As JFX
Private mainform As Form
Private sql1 As SQL
Private tbl_tableview As TableView
Private b4xtable1 As B4XTable
Dim DBFileDir As String
Dim DBFileName As String : DBFileName = "db.db"
Dim DBTableName As String
Dim dataDa,dataA As String
Private DateTemplate As B4XDateTemplate
End Sub
Sub AppStart (Form1 As Form, Args() As String)
mainform = Form1
mainform.RootPane.LoadLayout("Layout1") 'Load the layout file.
mainform.Title = "Layout1"
mainform.Show
tbl_tableview.Initialize("tbl_tableview")
mainform.RootPane.AddNode(tbl_tableview, 0, 0, 0, 0) 'values not important
mainform.RootPane.SetAnchors(tbl_tableview, 0, 0, 0, 0) 'will fill the whole screen
DateTemplate.Initialize
DateTemplate.MinYear = 2016
DateTemplate.MaxYear = 2030
DBFileName = "db.db"
DBTableName = "movimenti"
DBFileDir="c:\temp\prova\"
dataA=DateTime.Date(DateTemplate.Date)
dataDa= "01/01/2021"
b4xtable1.Initialize(Me, "B4XTable1")
Try
'Initialize database
sql1.InitializeSQLite(DBFileDir,DBFileName, True)
'sqlstring = "SELECT * FROM " & DBTableName
b4xtable1.AddColumn("Id", b4xtable1.COLUMN_TYPE_NUMBERS)
b4xtable1.AddColumn("tavolo", b4xtable1.COLUMN_TYPE_TEXT)
b4xtable1.AddColumn("codArt", b4xtable1.COLUMN_TYPE_TEXT)
b4xtable1.AddColumn("prezzo", b4xtable1.COLUMN_TYPE_TEXT)
b4xtable1.AddColumn("qta", b4xtable1.COLUMN_TYPE_TEXT)
b4xtable1.AddColumn("dataG", b4xtable1.COLUMN_TYPE_TEXT)
b4xtable1.AddColumn("flag", b4xtable1.COLUMN_TYPE_TEXT)
b4xtable1.AddColumn("rifer", b4xtable1.COLUMN_TYPE_TEXT)
b4xtable1.AddColumn("ora", b4xtable1.COLUMN_TYPE_TEXT)
b4xtable1.AddColumn("t2", b4xtable1.COLUMN_TYPE_TEXT)
b4xtable1.AddColumn("uf", b4xtable1.COLUMN_TYPE_TEXT)
Dim Data As List
Data.Initialize
Dim rs As ResultSet = sql1.ExecQuery("SELECT * FROM " & DBTableName)
Do While rs.NextRow
Dim row(11) As Object
row(0) = rs.GetDouble("Id")
row(1) = rs.GetString("tavolo")
row(2) = rs.GetString("codArt")
row(3) = rs.GetString("prezzo")
row(4) = rs.GetString("qta")
row(5) = rs.GetString("dataG")
row(6) = rs.GetString("flag")
row(7) = rs.GetString("rifer")
'Some of the values are Null. We need to convert them to empty strings:
If row(7) = Null Then row(7) = ""
row(8) = rs.GetString("ora")
row(9) = rs.GetString("t2")
row(10) = rs.GetString("ut")
Data.Add(row)
Loop
rs.Close
' CreateTableView
DBUtils.ExecuteTableView(sql1, "SELECT * FROM " & DBTableName, Null, 0, tbl_tableview)
b4xtable1.SetData(Data)
b4xtable1.Refresh
tbl_tableview.Visible=True
Catch
'When an error occurs the database most probably isn´t there.
xui.MsgboxAsync("Database cound't be found.", "Db.db")
End Try
End Sub
'Resize the tableview
Sub tbl_tableview_Resize (Width As Double, Height As Double)
Dim w As Double = (Width - 15) / tbl_tableview.ColumnsCount
For i = 0 To tbl_tableview.ColumnsCount - 1
tbl_tableview.SetColumnWidth(i, w)
Next
End Sub