Results 1 to 5 of 5

Thread: SQLite misbehaving

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default SQLite misbehaving

    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:
    Qt Code:
    1. QString sql;
    2. QSqlQuery query1(db);
    3.  
    4. sql="CREATE TABLE IF NOT EXISTS patients ("
    5. "dbID integer PRIMARY KEY AUTOINCREMENT,"
    6. "identificationNumber text,"
    7. "lastname text,"
    8. "firstname text,"
    9. "mi text);";
    10.  
    11. if (!query1.exec(sql)) {
    12. QMessageBox::critical(0, "", "Patients:" + query1.lastError().text());
    13. //return false;
    14. }
    To copy to clipboard, switch view to plain text mode 
    at application start up, then at user election, I do
    Qt Code:
    1. QSqlQuery query(db);
    2. query.prepare("INSERT INTO patients (lastname, firstname, mi, identificationNumber) "
    3. "VALUES (:lastname, :firstname, :mi, :identificationnumber);");
    4. query.bindValue(":lastname", pr.lastName);
    5. query.bindValue(":firstname", pr.firstName);
    6. query.bindValue(":mi", pr.MI);
    7. query.bindValue(":identificationnumber", pr.identificationNumber);
    8. if (!query.exec()) {
    9. QMessageBox::critical(0, "", "Patient add failed! " + query.lastError().text());
    10. return;
    11. }
    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.
    Last edited by Scorp1us; 22nd February 2007 at 23:42.

Similar Threads

  1. SQLite driver unavailable
    By kandalf in forum Installation and Deployment
    Replies: 5
    Last Post: 11th February 2009, 16:36
  2. Bulk insert into SQLite
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 19th November 2007, 03:56
  3. sqlite
    By spx2 in forum Qt Programming
    Replies: 9
    Last Post: 19th December 2006, 22:01
  4. Reading umlaut letters from sqlite database
    By Djony in forum Qt Programming
    Replies: 11
    Last Post: 17th November 2006, 10:30
  5. Sqlite & QPixmap Help please
    By munna in forum Qt Programming
    Replies: 2
    Last Post: 4th November 2006, 05:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.