sql - QtSQL with MS Access : UPDATE/DELETE queries not updating data -


i'm facing issue using qtsql along ms access database, using qobdc driver.

select , insert statement work, , read/insert data properly.

update/delete statements correctly processed (according qsqlquery , obdc tracer), in ms access, data not edited.

i'm using '?' bindings request, replacing these bindings hardcoded data didn't work either.

the obdc tracer sees update request, 2 bindings.

is there reason why these update statements not modify ms access' data ?

database

db = qsqldatabase::adddatabase("qodbc"); db.setdatabasename(qstring("driver={microsoft access driver (*.mdb, *.accdb)};dsn='';dbq=") + file); 

delete function

bool msaccessreader::deleterecord(qstring table, qstring where) {     qstring req;     req = qstring("delete ") + table + qstring(" ") + where;     qsqlquery query;     bool ok = query.exec(req);     return ok; } 

update function

bool msaccessreader::update(qlist<qstring> headers, qlist<qvariant> data, qstring where, qstring table) {     if(headers.isempty() || data.isempty())     {         qdebug() << "headers or data empty";         return false;     }     else if(headers.size() != data.size())     {         qdebug() << "number of headers , data fields mismatches";         return false;     }     else if(table.isempty())     {         qdebug() << "table isn't specified";         return false;     }     else if(where.isempty())     {         qdebug() << "where isn't specified";         return false;     }      qsqlquery query;     qstring req;      req = qstring("update ") + table + qstring(" set ");      foreach(qstring header, headers)     {         req = req + header + "=?,";     }      req = req.left(req.size()-1);      /*where*/     req = req + qstring(" ") + + qstring(";");      query.prepare(req);       foreach(qvariant var,data)     {         query.addbindvalue(var);     }       qdebug() << query.lastquery() << query.boundvalues();     bool ok = query.exec();     return ok; } 

request string , data

"update table1 set nom=?,prenom=? id=1;" qmap((":a", qvariant(qstring, "jean"))(":bb", qvariant(qstring, "marc"))) 

data table

enter image description here

found problem.

i needed exectue transaction() , commit() around query :

db.transaction(); bool ok = query.exec(); db.commit(); 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -