QSqlQuery的bindValue,占位符绑定不能多次匹配

写了个insert语句,因为最后部分用了“ON DUPLICATE KEY UPDATE”,所以值需要在整个语句中出现2次,用了ODBC的参数绑定方法,返回“Parameter count mismatch”错误。

query.bindValue(“:var1”, var);

于是查了Qt的帮助,赫然写着……

Values cannot be bound to multiple locations in the query, eg:

 INSERT INTO testtable (id, name, samename) VALUES (:id, :name, :name)

Binding to name will bind to the first :name, but not the second.

 

不能匹配多次-_-!!!