[Qt-interest] Sqlite query on Win CE returns no results
Andreas Unger
andi.unger05 at gmail.com
Sun Sep 27 21:40:35 CEST 2009
Hi all,
I wrote an app that uses an sqlite database. The dynamically built
applications works well on Linux.
The same code doesn't work on Windows CE. Just like on the Linux OS,
SQLITE is listed as one of the
supported database drivers in QSqlDatabase::drivers()
The only difference here is that the Win CE app is a static build. I'm
able to run the db.open() command,
but after that the sql query returns 0 results, even though it runs
multiple results on *nix.
I've also tried listing the current folder's content, to make sure
that it does find the sqlite database file,
and the file is there alright.
I tried the qt demo app, (/demos/sqlbrowser) and it too, doesn't work
on Win CE (loads up but list no query
results) yet it works on Linux.
Cheers,
Andreas
ps: Here is the test app:
#include <QtGui>
#include <QSqlDatabase>
#include <QSqlQuery>
//"SQLITE" shows up here
QString _results = "Supported SQL drivers: ";
for (int i = 0; i < QSqlDatabase::drivers().size(); i++){
_results.append(QSqlDatabase::drivers().at(i));
_results.append(" ");
}
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("test.db");
if (!db.open()) {
QMessageBox::critical(0, qApp->tr("Cannot open database"),
qApp->tr("Unable to establish a database connection.\n\n"
"Click Cancel to exit."), QMessageBox::Cancel);
return false;
}
QSqlQuery query;
QLabel *_label = new QLabel;
_results.append("\n\nSQL Query Results:\n\n");
query.exec("SELECT * FROM Test_Items;");
while (query.next()) {
_results += query.value(0).toString();
_results.append("\n");
}
_label->setText(_results);
_label->show();
return app.exec();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090927/2d1c748c/attachment.html
More information about the Qt-interest-old
mailing list