Private Sub Button1_Click
'xui.MsgboxAsync("Hello world!", "B4X")
Dim sb As StringBuilder
SQL1.InitializeSQLite(File.DirApp, "caisse.db", True)
' --- Check for empty table
Dim RowsCount As Int = getRowCount("tickets", "id")
Log(RowsCount)
If RowsCount = 0 Then
' --- Delete whole database
File.Delete(File.DirApp, "caisse.db")
' --- Copy default database
File.Copy(File.DirAssets, "caisse.db",File.DirApp, "caisse.db")
End If
Dim res As ResultSet = SQL1.ExecQuery($"
select
theticket,
max(montant) as montantmax,
nombre,
heure
from (
Select ticket as theticket,
Sum(qte) As nombre,
Sum(qte * prix) As montant,
heure
From tickets
group by ticket)
where
heure >= '2021-01-01' and heure < '2021-07-22'
"$)
If res.ColumnCount > 0 Then
sb.Initialize
For x = 0 To res.ColumnCount - 1
sb.Append($"${res.GetColumnName(x)} "$)
Next
Log(sb.ToString)
End If
Do While res.NextRow
sb.Initialize
For x = 0 To res.ColumnCount - 1
sb.Append($"${res.GetString2(x)} "$)
Next
Log(sb.ToString)
Loop
res.Close
SQL1.Close
End Sub