duave,
The only thing that I see strange with your code is the following line but then I am no expert either.
timingDatabase
= QSqlDatabase::addDatabase("QSQLITE",
"timing");
timingDatabase = QSqlDatabase::addDatabase("QSQLITE", "timing");
To copy to clipboard, switch view to plain text mode
I am not sure about the "timing" being in the definition. To do what you want I did it this way:
timeQuery.exec( "CREATE TABLE IF NOT EXISTS timing ("
"`line1` varchar(10) default NULL,"
"`line2` varchar(10) default NULL,"
"`line3` varchar(10) default NULL)" );
if (!timeQuery.isActive() )
{
QMessageBox::critical(this,
"Error",
"Table Creation Failed! \n" "\n"+dbqry.lastError().text()+"n"+timingDatabase.driverName() );
}
timeQuery.exec( "CREATE TABLE IF NOT EXISTS timing ("
"`line1` varchar(10) default NULL,"
"`line2` varchar(10) default NULL,"
"`line3` varchar(10) default NULL)" );
if (!timeQuery.isActive() )
{
QMessageBox::critical(this, "Error", "Table Creation Failed! \n"
"\n"+dbqry.lastError().text()+"n"+timingDatabase.driverName() );
}
To copy to clipboard, switch view to plain text mode
I have an application that requires three tables and I use this method to check each table is there. If not, its created. Also, the the database is created if not there either.
Hope this helps.
B1.
Bookmarks