title: parameter count mismatch in parameterized query
body: <p>I am using quite a lot of parameterized queries in my code for performance reasons. In short, some of them work, some don't.</p>
  
  <p>I initialize the query during construction of my database wrapper like this:</p>
  
  <pre><code>QString querystring = QString("SELECT somevalue FROM sometable "
                        "WHERE one_feature = :one_feature AND other_feature = :other_feature ");
  myquery = QSqlQuery(db);
  myquery.setForwardOnly(true);
  myquery.prepare(querystring);
  </code></pre>
  
  <p><code>myquery</code> is a <code>QSqlQuery</code> member variable of my database wrapper. Later on, in the function that wants to use this query, I do something like</p>
  
  <pre><code>int db_wrapper::fetch_some_value (int arg1, int arg2) {
      myquery.clear();
      myquery.bindValue(":one_feature", arg1);
      myquery.bindValue(":other_feature", arg2);
  
      qDebug() &lt;&lt; "Bound values: " &lt;&lt; myquery.boundValues();
  
      bool OK = myquery.exec();
      if (!OK) {
          int number = myquery.lastError().number();
          qDebug() &lt;&lt; "db error " &lt;&lt; number;
          qDebug() &lt;&lt; "db error " &lt;&lt; myquery.lastError().text();
  
  #ifdef USE_EXCEPTIONS
          throw "Could not fetch some_value!";
  #endif
      }
  
      // process data...
  }
  </code></pre>
  
  <p>I always get the same error message/output:</p>
  
  <pre><code>Bound values:  QMap((":one_feature", QVariant(int, 1) ) ( ":other_feature" ,  QVariant(int, 1) ) )  
  db error  -1 
  db error  " Parameter count mismatch" 
  terminate called after throwing an instance of 'char const*'
  </code></pre>
  
  <p>The exception is not surprising, but the parameter count mismatch is. The call to <code>boundValues</code> actually shows the right values and all, still I get this error message. I have similar queries that work just fine.</p>
  
  <p>I tried substituting positional bind values, renamed the placeholders, used <code>?</code> and positional bind values, all to no avail. Does anyone have an idea what the problem might be?</p>
  
  <p>I use Qt 4.7.3 and SQLite 3.7.4-2</p>