• 3363阅读
  • 1回复

[提问]数据库事务处理 [复制链接]

上一主题 下一主题
离线searchcai
 

只看楼主 倒序阅读 楼主  发表于: 2013-04-26
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.


这里的Note:说有些数据在提交前必须先将query 置为无效,用clear()或finish()。  那说的数据库时哪些数据库啊?

没有关于事务处理的样例代码参考一下。
  
离线jdwx

只看该作者 1楼 发表于: 2013-04-26
回 楼主(searchcai) 的帖子
开始事务处理
if(transaction() )
{
...... insert......
//提交
commit()
}
发帖时要说明:操作系统、Qt版本、编译器,这样能更快的得到回复。
快速回复
限100 字节
 
上一个 下一个