File missing error for: /QtSql/private/qsqlcachedresult_p.h [SOLVED]



  • I am using Qt Creator 2.1.0 on Linux Mint

    I have been researching how to connect to a SQLite database and in the process I added an include for <QtSql/qsql_sqlite.h>. I am now getting the file missing error. The QTSql folder doesn't have a sub-folder named private.
    X
    Also, in the past I have always used a connection string like:
    "Data Source=/Home/Mark/Databases/MotorData.sqlite;Version=3;New=False;Compress=True;"
    I'm having difficulty time finding a similar reference in the Qt documentation. Doesn't the SQLite wrapper need the above info?

    Your help is most appreciated.



  • To use a SQLite database:

    • add the sql module to your .pro file (QT += sql).
    • include <QtSql/QSqlDatabase>
    • use QSqlDatabase::addDatabase("QSQLITE") to get a database object
    • set the SQLite filename using setDatabaseName()

    Just see the various "examples":http://qt.gitorious.org/qt/qt/blobs/4.7/examples/sql/connection.h.



  • In your applications, do not rely on private headers. They may or may not be available, and they may change or be removed at any time, at any release.



  • [quote author="Lukas Geyer" date="1321339075"]To use a SQLite database:

    • add the sql module to your .pro file (QT += sql).
    • include <QtSql/QSqlDatabase>
    • use QSqlDatabase::addDatabase("QSQLITE") to get a database object
    • set the SQLite filename using setDatabaseName()

    Just see the various "examples":http://qt.gitorious.org/qt/qt/blobs/4.7/examples/sql/connection.h.[/quote]

    Most of what you suggested I already had in place. The thing I find that seems significant is there is no example for connecting to an existing database. Connecting to an in memory database following the example provides a connection as expected. However, I am trying to connect to an existing database. Most all posts show using a windows path. So how is setDatabaseName used when you have an existing database?



  • Just point to your existing database file.
    @
    database.setDatabaseName("c:/path/to/database.file");
    @



  • Thanks for your patience. Life is good again.:)



  • You're welcome. Feel free to edit the topic to "[Solved] ..." if it has been solved for you to indicate that it actually is and that there is a solution inside.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.