On 02/14/2014 01:11 PM, igor.mironc...@gmail.com wrote: > I’m trying to insert new record to the table with: > QSqlRecord r; > r.setValue( 0, 0 ); > r.setValue( 1, QString() ); > r.setValue( 2, QString() ); > r.setValue( 3, QString() ); > if( !d->model->insertRecord( -1, r ) ) > QMessageBox::critical( 0, tr( "Database Error..." ), > tr( "Couldn't insert new record into database.\n%1" ) > .arg( d->model->lastError().isValid() ? > d->model->lastError().text() : QString() ) > ); > But I received the error: “No Fields to update”. And new record wasn’t > inserted. I’ve tried to call d->model->insertRow( –1 ) but this failed too > without any error. > What am I doing wrong? Or may be it’s a bug? >
> I’ve found the problem... The problem solved with: > QSqlRecordr=d->model->record(); > The critical factor is the generated flag on the fields in the record. QSqlTableModel generates SQL only for the fields with generated set to "true". Mark _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest