File missing error for: /QtSql/private/qsqlcachedresult_p.h [SOLVED]
-
wrote on 15 Nov 2011, 06:26 last edited by
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.
-
wrote on 15 Nov 2011, 06:37 last edited by
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.
-
wrote on 15 Nov 2011, 11:54 last edited by
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.
-
wrote on 15 Nov 2011, 13:55 last edited by
[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?
-
wrote on 15 Nov 2011, 14:49 last edited by
Just point to your existing database file.
@
database.setDatabaseName("c:/path/to/database.file");
@ -
wrote on 15 Nov 2011, 16:09 last edited by
Thanks for your patience. Life is good again.:)
-
wrote on 15 Nov 2011, 16:44 last edited by
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.
1/7