Hi!!
Basically I want to do a simplified keyword search using the following SQL query;
SELECT body,created_on FROM entries WHERE body LIKE '%term%' ORDER BY created_on;
In the SQLite command line I receive the result set I expect. When I transfer it to Qt it simply does not work. I have tried the following;
Code:
QSqlQuery query; query.prepare( "SELECT body,created_on FROM entries WHERE body LIKE '%?%' ORDER BY created_on" ); query.addBindValue( term ); query.exec();
As well as named bindings;
Code:
QSqlQuery query; query.prepare( "SELECT body,created_on FROM entries WHERE body LIKE '%:term%' ORDER BY created_on" ); query.bindValue( ":term", term ); query.exec();
The QSqlError I get in both cases is reported as 2. The error text is "parameter count mismatch" in both cases.
Note a similar query applied without a conditional works fine in QT. The query that works is as follows;
Code:
query.prepare( "SELECT body,created_on FROM entries ORDER BY created_on" );
Hard coding a value also works;
Code:
query.prepare( "SELECT body,created_on FROM entries WHERE body LIKE '%term%' ORDER BY created_on" );
Obviously there is something I am missing. Are % not allowed when used with a bound value? I've skimmed through the documentation and haven't seen anything that would imply such limitations.
Any help would be greatly appreciated.
Nate
System Info:
~~~~~~~~
Mac OS X Tiger
QT 4.3.2
g++ v4.0.1