I'm by using this code to produce a database. But I get "false" in debug. I attempted a great deal nevertheless its no longer working. What's the error within this?

 QSqlQuery query;
qDebug() << query.exec("CREATE TABLE glucose (id INTEGER PRIMARY KEY AUTOINCREMENT, value INTEGER, date TEXT, time TEXT, duration TEXT, note TEXT");

   qDebug() << query.prepare("INSERT INTO glucose(id, value, date, time, duration, note)""VALUES(?, ?, ?, ?, ?, ?)");

   query.bindValue(1,edit_glucose->text().toInt());

   query.bindValue(2,datetime->date());

  query.bindValue(3,datetime->time());

  query.bindValue(4,"a");

   query.bindValue(5,edit_note->toPlainText());
   qDebug() << query.exec();

you forget to close your CREATE TABLE query with ")"

QSqlQuery has got the method lastError(), returns error information :)

You're passing within the INSERT query the id area. You have to take it off.

The query ought to be:

Debug() << query.prepare("INSERT INTO glucose(value, date, time, duration, note) 
                                      VALUES(?, ?, ?, ?, ?)");