February 2019
Beginner
136 pages
3h 7m
English
The UPDATE operation follows the same logic as the DELETE operation. Consider the following lines of code:
// Update a recordQSqlQuery update_statement(db_conn);update_statement.exec("UPDATE contacts SET first_name='Jude' WHERE id=1 ");qDebug() << "Number of rows affected: " << update_statement.numRowsAffected();
The statement here sets the first_name of the record with an ID of 1 to 'Jude'. update_statement.numRowsAffected() will return nothing, especially in the case where the first record in the table with id=1 is missing. Do take note of this.
The full program to illustrate the major operations is outlined as follows:
#include <QApplication>#include <QtSql>#include <QDebug>int main(int argc, char *argv[]) { // Setup ...Read now
Unlock full access