[Qt-interest] Sqlite query on Win CE returns no results
Andreas Unger
andi.unger05 at gmail.com
Sun Sep 27 21:56:41 CEST 2009
Apologies, the application works on Win CE as well, albeit with one small
issue. It looks for the db at the root directory
instead of the current directory. However, it looks for all the other files
used in my application in the current directory, which
is a little weird...
Cheers,
Andreas
On Sun, Sep 27, 2009 at 3:40 PM, Andreas Unger <andi.unger05 at gmail.com>wrote:
> 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/d5b4c451/attachment.html
More information about the Qt-interest-old
mailing list