I have two database connections (SQLITE).
The second one is created by:
bool MainWindow
::createConnection(const QString &id
) {
db.setDatabaseName(databasePanels);
db.open();
/
if (db.isOpen())
return true;
else
return false;
}
bool MainWindow::createConnection(const QString &id)
{
databasePanels = QCoreApplication::applicationDirPath()+"/panels.db";
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE",id);
db.setDatabaseName(databasePanels);
db.open();
/
if (db.isOpen())
return true;
else
return false;
}
To copy to clipboard, switch view to plain text mode
void MainWindow
::createTablePanel(const QString &type
) {
db.setDatabaseName(databasePanels);
q.prepare(" create table pannelli ( id INTEGER NOT NULL PRIMARY KEY,costruttore VARCHAR(50),modello VARCHAR(50),pnom )");
q.exec();
}
void MainWindow::createTablePanel(const QString &type)
{
QSqlDatabase db=QSqlDatabase::database(type);
db.setDatabaseName(databasePanels);
QSqlQuery q(db);
q.prepare(" create table pannelli ( id INTEGER NOT NULL PRIMARY KEY,costruttore VARCHAR(50),modello VARCHAR(50),pnom )");
q.exec();
}
To copy to clipboard, switch view to plain text mode
but I get:
createTablePanel.: QSqlError(-1, "Unable to fetch row", "No query") "
why?
Bookmarks