PDA

View Full Version : Strange behavior of QSqlTableModel



venomj
13th January 2010, 03:29
Hi, I use a QSqlTableModel and a QTableView to add/delete/modify data from a SQL Server db table.
While the adding works fine, I cannot properly delete a database record by calling QSqlTableModel::removeRows.
The removeRows call did return true, but the submitAll returned an error "QODBCResult::exec: Unable to execute statement:"
It took me some time to find out that by setting the primary key in the database table sloved the problem.
My question is do I need primary keys for all database tables to use the QSqlTableModel ?
Is it designed this way or is there something more I need to do before calling removeRow?