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;

Qt Code:
  1. QSqlQuery query;
  2. query.prepare( "SELECT body,created_on FROM entries WHERE body LIKE '%?%' ORDER BY created_on" );
  3. query.addBindValue( term );
  4. query.exec();
To copy to clipboard, switch view to plain text mode 

As well as named bindings;

Qt Code:
  1. QSqlQuery query;
  2. query.prepare( "SELECT body,created_on FROM entries WHERE body LIKE '%:term%' ORDER BY created_on" );
  3. query.bindValue( ":term", term );
  4. query.exec();
To copy to clipboard, switch view to plain text mode 

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;

Qt Code:
  1. query.prepare( "SELECT body,created_on FROM entries ORDER BY created_on" );
To copy to clipboard, switch view to plain text mode 

Hard coding a value also works;

Qt Code:
  1. query.prepare( "SELECT body,created_on FROM entries WHERE body LIKE '%term%' ORDER BY created_on" );
To copy to clipboard, switch view to plain text mode 

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