February 2019
Beginner
136 pages
3h 7m
English
In order to execute query statements against the database, we shall make use of the QSqlQuery class. These statements include data-altering statements, such as INSERT, SELECT, and UPDATE. Data definition statements such as CREATE TABLE can also be issued.
Consider the following snippet of code to list all entries within the contacts table:
QSqlQuery statement("SELECT * FROM contacts", db_conn);QSqlRecord record = statement.record();while (statement.next()){ QString firstName = statement.value(record.indexOf("first_name")).toString(); QString lastName = statement.value(record.indexOf("last_name")).toString(); QString phoneNumber = statement.value(record.indexOf("phone_number")).toString(); qDebug() << firstName << " - " << ...Read now
Unlock full access