QSqlDatabase my_db = QSqlDatabase::addDatabase("QODBC3","my_conn"); QString str_conn="DRIVER={Microsoft Access Driver (*.mdb)};FIL={MSAccess};DSN='MSAccess';DBQ=C:/db/my_base.mdb"; my_db.setDatabaseName(str_conn); if(!my_db.open())//сообщим {
SqlQuery qry(QSqlDatabase::database("my_conn"));bool is_good=true;QSqlDatabase::database("lit_conn").transaction();is_good=qry.exec("DELETE ...");if(is_good && .....) is_good=qry.exec("INSERT INTO ....");if()if()if()if(is_good){ QSqlDatabase::database("my_conn").commit();else QSqlDatabase::database("my_conn").rollback();
QSqlDatabase::database("ххх").transaction();...QSqlDatabase::database("ххх").commit();
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3","my_conn");...db.exec("BEGIN TRANSACTION");....if(is_good) {db.exec("COMMIT");} else {db.exec("ROLLBACK");}