sqlite sorting

dennishea

Active Member
Licensed User
Help I can't seem to wrap my brain around sorting. If I have data in a colume that looks like this.

Mach
-----

Tht2d
Tht3
Twf4
T-I20

When I enter txt like Tht in txtbox I would like to load Tht2d and Tht3 in table, not twf4 and T-I20 or if I load txtbox with Twf4 that is all I want to show up in table. I can't seem to figure out how to enter partial data and match up with data in database. Any help would be appreciated.

denny
 

BjornF

Active Member
Licensed User
You can do it using wildcards (e.g. *).

either with a table filter on the "local" table, e.g. Table1.Filter("FirstColumnContent LIKE 'tht*'"), or alternatively you could do a query to the SQLite database e.g. "SELECT * FROM MainTable WHERE FirstColumnContent LIKE 'tht*'"

all the best / Björn
 

Hennell

Member
Licensed User
alternatively you could do a query to the SQLite database e.g. "SELECT * FROM MainTable WHERE FirstColumnContent LIKE 'tht*'"
For some reason in SQLite the * wildcard is actually a %, so the command should be:

"SELECT * FROM MainTable WHERE FirstColumnContent LIKE 'tht%'"

This works best with the cmd.setparameter feature as you can add the '%' in within the code:

B4X:
cmd.SetParameter("Search","%" & tbxSearch.Text & "%")
cmd.CommandText = "SELECT * FROM MainTable WHERE FirstColumnContent LIKE @Search"
 

dennishea

Active Member
Licensed User
Thanks BjornF and Hennell for your responses. I now am back out of the quag myer and progressing again. Thanks again to both of you for your help.

:sign0188:

dennishea :sign0060:
 
Top