search all letters in my database

Fox

Active Member
Licensed User
Longtime User
hello i make an searchbox they search in my complete list as the input string but my problem is.. if i input anythink just the first letter was used by the search... here is the code:

Sub Searchbox_TextChanged (Old As String, New As String)
Cursor = ST.ExecQuery("Select DISTINCT * FROM database WHERE music or artist like '%" & Searchbox.Text & "%' ORDER BY 'Music';")
lvNames.Clear
For i = 0 To Cursor.RowCount - 1
Cursor.Position = i
lvNames.AddSingleLine(Cursor.GetString(db))
Next
Cursor.Close
End Sub

how can i make it that all search strings be considered?
 

Smee

Well-Known Member
Licensed User
Longtime User
as an aside, if you use strToUpper or strToLower in your query you should be able to catch upper and lower case as well
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Instead of using Searchbox.Text in your query, try using New, as this is the new string in Searchbox.
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
Your query looks correct. If you enter abc then it will return all values that contain abc like abcdef and zabcd.

I have tested the code, but the result is not correct, because the search was only in one column (music).

This code brings the correct result:
B4X:
Cursor = ST.ExecQuery("SELECT * FROM database WHERE music LIKE '%"&Searchbox.Text&"%' OR artist LIKE '%"&Searchbox.Text&"%' GROUP BY Music")
;)
 
Upvote 0
Top