'add those at class_globals:
Dim SQLsearch As String = ""
Dim SQLtable As String ' the table you will show/search...
Dim SQLargs As List 'the args can be the all the columns as you can see in this example... auto-creating....
Dim sql1 As String ' here can be the column/fields of table you wanna show for example: id, customername, telephone, email
Private Sub searchtext_EnterPressed
searchtext.TextField.SelectAll
btnsearch_Click
End Sub
Private Sub btnsearch_Click
If searchtext.Text.ToLowerCase.Trim.Length>0 Then
Dim searchtocolumns() As String = Regex.Split(" ",searchtext.Text.ToUpperCase) '...i like uppercase all letters... i am doing that when writting to db too... especially at sqlite databases... because of limitations they have...
Dim newargs As String
Dim sb2 As StringBuilder
sb2.Initialize
SQLargs.Clear
Dim rs As ResultSet = datadb.ExecQuery("SELECT " & sql1 & " FROM " & SQLtable & " LIMIT 1")
For I = 0 To searchtocolumns.Length-1
sb2.Append("(")
For K = 0 To rs.ColumnCount-1
sb2.append("upper(").Append(rs.GetColumnName(K)).Append(")").Append(" LIKE ?")
SQLargs.Add("%" & searchtocolumns(I).ToUpperCase & "%")
If K<rs.ColumnCount-1 Then
sb2.Append(" OR ")
End If
Next
sb2.Append(")")
If I<searchtocolumns.Length-1 Then
sb2.Append(" AND ")
End If
Next
newargs=sb2.ToString
rs.CLOSE
B4XTable1.BuildQuery(False)
SQLsearch="SELECT " & sql1 & " FROM "& SQLtable & " WHERE " & newargs
LoadData 'a sub that you will load all values of database you want to a b4xtable - there are many examples.... using sqlsearch... ofcourse there are many other ways....
Else
' ...here you can show all your records...
End If
End Sub