Posted on 2010-09-12 09:16
Tommy Liang 阅读(591)
评论(0) 编辑 收藏 引用
在如下系列中:
1、QSqlQuery q("select count(*) from sometable where name=:name");
...
2、QSqlDatabase::database().transaction();
....
在1和2之间如果不清除q,是会锁死的,答案在这里:
bool QSqlDatabase::commit ()
Commits a transaction to the database if the driver supports transactions and a transaction() has been started. Returns true if the operation succeeded. Otherwise it returns false.
Note: For some databases, the commit will fail and return false if there is an active query using the database for a SELECT. Make the query inactive before doing the commit.
Call lastError() to get information about errors.
See also QSqlQuery::isActive(), QSqlDriver::hasFeature(), and rollback().