I have upgraded to SQLite 3.3.13. I don't know if that is a problem or not, because Qt came with 3.2.7.
But my problem is I run a simple query:
sql="CREATE TABLE IF NOT EXISTS patients ("
"dbID integer PRIMARY KEY AUTOINCREMENT,"
"identificationNumber text,"
"lastname text,"
"firstname text,"
"mi text);";
if (!query1.exec(sql)) {
QMessageBox::critical(0,
"",
"Patients:" + query1.
lastError().
text());
//return false;
}
QString sql;
QSqlQuery query1(db);
sql="CREATE TABLE IF NOT EXISTS patients ("
"dbID integer PRIMARY KEY AUTOINCREMENT,"
"identificationNumber text,"
"lastname text,"
"firstname text,"
"mi text);";
if (!query1.exec(sql)) {
QMessageBox::critical(0, "", "Patients:" + query1.lastError().text());
//return false;
}
To copy to clipboard, switch view to plain text mode
at application start up, then at user election, I do
query.prepare("INSERT INTO patients (lastname, firstname, mi, identificationNumber) "
"VALUES (:lastname, :firstname, :mi, :identificationnumber);");
query.bindValue(":lastname", pr.lastName);
query.bindValue(":firstname", pr.firstName);
query.bindValue(":mi", pr.MI);
query.bindValue(":identificationnumber", pr.identificationNumber);
if (!query.exec()) {
QMessageBox::critical(0,
"",
"Patient add failed! " + query.
lastError().
text());
return;
}
QSqlQuery query(db);
query.prepare("INSERT INTO patients (lastname, firstname, mi, identificationNumber) "
"VALUES (:lastname, :firstname, :mi, :identificationnumber);");
query.bindValue(":lastname", pr.lastName);
query.bindValue(":firstname", pr.firstName);
query.bindValue(":mi", pr.MI);
query.bindValue(":identificationnumber", pr.identificationNumber);
if (!query.exec()) {
QMessageBox::critical(0, "", "Patient add failed! " + query.lastError().text());
return;
}
To copy to clipboard, switch view to plain text mode
And it tells me that database is locked.
I also noticed that the application SEEMS to hold a lock on the database, so the application has to be exited before the tables are created... I've done ODBC with Qt with no problems. Anyone have an idea on SQLite? is ti a driver setting?
EDIT: Added db.transaction() and db.commit(), still no joy.
Bookmarks