Thanks Patrick - I was just reading that when you posted me the link
Just realised though -
If I remove only the leading %, only the trailing %, or both - the search fails silently?
[code]// PREPARE THE STATEMENT
Dim ps As SQLitePreparedStatement = db.Prepare(“SELECT * FROM Snippets WHERE Title LIKE ?;”)
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
// BIND THE SEARCH STRING AND EXECUTE
ps.Bind(0, TextField1.text + “%”)
Dim rs as Recordset = ps.SQLSelect[/code]
Well, then you’ll need the %SearchTerm% variant and you’ll need to be aware of the fact it initiates a leading wildcard search and monitor for performance problems if the table gets large.
It’s perfectly understandable when you get under the hood of the database engine - it makes sense. So, that’s why we have Full Text Search available for the bigger datasets.
Just when I thought I had a basic understanding of prepared statements - this threw me.
After my listbox is only displaying rows containing the search string, I need to re-populate the database with ALL the entries again.
I am trying to use a prepared statement in a button, but I have no idea how to formulate the code:
What do I bind to the question mark???
[code] // PREPARE THE STATEMENT
Dim ps As SQLitePreparedStatement = db.Prepare(“select SRef, Title, Code from Snippets order by Title Asc ?;”)
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
// BIND
ps.Bind(0,)
Dim rs as Recordset = ps.SQLSelect[/code]
[quote=92392:@Patrick Delaney]Fails or nothing in the table matches the search?
To be clear
%SearchTerm - searches for any column where the text STARTS with the SearchTerm (leading wildcard search)
SearchTerm% - searches for any column where the text ENDS with the SearchTerm. Trailing wildcard search and DB can use an index
[/quote]
I think you have these two reversed
%SearchTerm will find it where the text in the DB ENDS with SearchTerm (% matches anything preceding search term)
SearchTerm% will find it where the text in the DB STARTS with SearchTerm (matches search term followed by anything)