February 2019
Beginner
136 pages
3h 7m
English
To effect a database operation to store data into the database, there are a number of ways to issue out the INSERT statement.
Consider one form of the INSERT operation in Qt:
// Insert new contactsQSqlQuery insert_statement(db_conn);insert_statement.prepare("INSERT INTO contacts (last_name, first_name, phone_number)" "VALUES (?, ?, ?)");insert_statement.addBindValue("Sidle");insert_statement.addBindValue("Sara");insert_statement.addBindValue("+14495849555");insert_statement.exec();
The QSqlQuery object, insert_statement, is instantiated by passing the database connection. Next, the INSERT statement string is passed to a call to prepare(). Notice how incomplete our statement is with the use of the three (3) ?, ?, ? (question ...
Read now
Unlock full access