Results 1 to 7 of 7

Thread: QSQLITE driver issue

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2006
    Posts
    64
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSQLITE driver issue

    G'Day,

    I am trying to write a simple app using Sqlite. (normally use MySql). My problem is that it creates the file "nksalvo.db", says that it is open, but the "create" commands fail saying the driver is not loaded. The "table 1 creation" message return the driver name as QSQLITE so it does appear to be loaded.

    I am using Qt 4.5.0 statically compiled, on windows ( at the moment - Linux next )

    I am guessing the error is somewhere else, but where?

    Any pointers would much appreciated...thanks B1.

    Qt Code:
    1. int MainWindow::openDatabase()
    2. {
    3. if (dbopen == true )
    4. {
    5. return 0;
    6. }
    7. else
    8. {
    9. // Create connection to database server
    10. nksalvoDB = QSqlDatabase::addDatabase( "QSQLITE" );
    11. nksalvoDB.setDatabaseName( cwdir+"/nksalvo.db" );
    12. if ( !nksalvoDB.open() )
    13. {
    14. QMessageBox::critical( this, "NKSalvo Database Error",
    15. "Could not connect to the database!\n"
    16. "\n"
    17. "Reported error:\n"
    18. +nksalvoDB.lastError().driverText()+"\n"
    19. +nksalvoDB.lastError().databaseText()+"\n"
    20. +nksalvoDB.databaseName()+"\n");
    21. dbopen = false;
    22. return 1;
    23. }
    24. createtableqry.prepare( "CREATE TABLE IF NOT EXISTS serialdata (`port` varchar(10) default NULL,"
    25. "`speed` varchar(6) default NULL,`databits` varchar(4) default NULL,"
    26. "`parity` varchar(5) default NULL, `stopbits` varchar(4) default NULL"
    27. "`id` smallint(2) NOT NULL, PRIMARY KEY (`id`)" );
    28. createtableqry.exec();
    29. if (!createtableqry.isActive() )
    30. {
    31. QMessageBox::critical(this, "Salvo Error", "Table 1 Creation Failed! \n"
    32. "\n"+createtableqry.lastError().text()+"\n"+nksalvoDB.driverName() );
    33. dbopen = false;
    34. return 1;
    35. }
    36. createtableqry.prepare( "CREATE TABLE IF NOT EXIST salvodata (butlabel string, butcolour string, row1 string,"
    37. "row2 string, row3 string, row4 string, row5 string,"
    38. "row6 string, row7 string, row8 string, row9 string,"
    39. "row10 string, id int NOT NULL, PRIMARY KEY (`id`))");
    40. createtableqry.exec();
    41. if (!createtableqry.isActive() )
    42. {
    43. QMessageBox::critical(this, "Salvo Error", "Table 2 Creation Failed! \n"
    44. "\n"+createtableqry.lastError().text()+"\n"+nksalvoDB.driverName());
    45. dbopen = false;
    46. return 1;
    47. }
    48. dbopen = true;
    49. return 0;
    50. }
    51. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by b1; 17th May 2009 at 06:30. Reason: Added more info....

Similar Threads

  1. QDevelop SQLite Driver Issue
    By Phan Sin Tian in forum Qt-based Software
    Replies: 4
    Last Post: 1st August 2010, 11:47
  2. Possible OpenGL / Intel driver issue
    By Truder in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 11:06
  3. SQLite driver unavailable
    By kandalf in forum Installation and Deployment
    Replies: 5
    Last Post: 11th February 2009, 16:36
  4. How do I get Qt to recognize the oci driver.
    By yleesun in forum Qt Programming
    Replies: 11
    Last Post: 19th January 2009, 03:50
  5. Replies: 1
    Last Post: 7th July 2008, 20:13

Tags for this Thread

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.