PDA

View Full Version : How do I create a new table using QSQL mods



Harvey West
14th December 2006, 19:01
Tried this but does not work

QString cmd = "CREATE TABLE example(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT)";
QSqlQuery query;
query.exec(cmd);

qDebug() << query.lastError();
reports: QSqlError(-1, """", """")

jacek
14th December 2006, 19:10
What do you mean by "does not work"? Do you connect to the database? Does this statement work, if you execute it from the SQL console?

Harvey West
15th December 2006, 17:03
No worries - Typo - works now.
Was on the right path which is nice to know. Cheers.