Take the 2-minute tour ×  if (!db.open()) {     qDebug() <<
"Database open error." << db.lastError();  QSqlQuery query(db);
query.prepare("create table if not exists dew (id int, title
varchar(255) not null)"); if (!query.exec()) {     qDebug() <<
"Query exec error. " << query.lastError(); qDebug() << "Insert
query exec OK";  if (!query.exec("insert into dew(id, title)
values (1, 'hello')")) qDebug() << query.lastError();  Shows the
output as  Insert query exec OK  QSqlError(1, "Unable to execute
statement", "table dew has no column named id")  Insertion
finished.   Table creation seems to be OK. But where is id
field? I'm confused with this code. I test
query.record().contains("id"); and it is false  share|improve
this question If, before you run that code, a table named dew
exists without an id column, that table won't be changed. Did
you check? –  Mat Apr 6 '12 at 10:55 Well! You guessed right!
But another thing, :temp: should suppossed to be deleted after
the exec finishes. But it stays. –  Dewsworld Apr