×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    13

    Existing SQLite DB in Symbian App

    Hi all,
    I'm currently writing an app that needs to read data from an SQLite DB that will be deployed with the application. It is intended that this application will run on the Nokia N8. However, after reading the various 'examples' of using SQLite in Qt I have still not been able to read any data from the db file. Can anyone help? Are there any tutorials that specifically demonstrate what to me should be a fairly straightforward task?

    Thanks in advance

    Angus

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Existing SQLite DB in Symbian App

    have you checked the wiki examples, you might not be to get simpler then that .
    Also can you let us know what you have tried till now.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    13

    Re: Existing SQLite DB in Symbian App

    Hi Sunil,
    here's my database connection manager :

    #ifndef NTDATABASEMANAGER_H
    #define NTDATABASEMANAGER_H
    #include <QtSql>
    #include <QObject>
    #include <QSqlDatabase>
    #include <QSqlError>
    #include <QFile>

    class NTDatabaseManager : public QObject
    {
    Q_OBJECT
    public:
    explicit NTDatabaseManager(QObject *parent = 0);
    ~NTDatabaseManager();

    public:
    bool openDB();
    bool deleteDB();
    QSqlError lastError();
    bool selectPlaceNames();

    private:
    QSqlDatabase db;

    };

    #endif // NTDATABASEMANAGER_H
    #include "ntdatabasemanager.h"
    #include <QSqlTableModel>
    #include <QSqlQuery>
    #include <QDebug>
    #include <QSqlRecord>
    #include <QFileInfo>


    NTDatabaseManager::NTDatabaseManager(QObject *parent) :
    QObject(parent)
    {
    }

    bool NTDatabaseManager:penDB()
    {
    bool isOpen = false;
    // Find QSLite driver
    db = QSqlDatabase::addDatabase("QSQLITE");

    db.setDatabaseName(":/ntdb/db/nationaltrust.sqlite");

    // Open database
    isOpen = db.open();

    QSqlQuery query(db);
    query.exec("SELECT * FROM ZASSET");
    qDebug() << "Last error :: " << query.lastError();
    while (query.next())
    {
    //some retrieval code here
    }
    if(!query.exec()){
    qDebug() << "Last error :: " << query.lastError();
    }

    QSqlRecord rec = query.record();
    qDebug("%d", rec.count());

    return isOpen;
    }

    QSqlError NTDatabaseManager::lastError()
    {
    // If opening database has failed user can ask
    // error description by QSqlError::text()
    return db.lastError();
    }

    bool NTDatabaseManager::selectPlaceNames()
    {
    bool ret = false;

    QSqlQuery query("SELECT * FROM ZASSET");
    while (query.next())
    {

    ret = true;
    }

    QSqlRecord rec = query.record();
    qDebug("%d", rec.count());

    return ret;

    }
    bool NTDatabaseManager::deleteDB()
    {
    db.close();
    return false;
    }

    NTDatabaseManager::~NTDatabaseManager()
    {

    }
    The pro file includes this line : QT += sql

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    13

    Re: Existing SQLite DB in Symbian App

    Hi again Sunil,
    it's OK I've managed to fix it. Had shadow-build checked!

    Thanks for your help

    Angus

Similar Threads

  1. Add existing Sqlite database to Qt project
    By santijdelatorre in forum Qt
    Replies: 31
    Last Post: 2011-05-15, 01:20
  2. Fast DB Transaction in SQLite in Qt for Symbian/Maemo.
    By narendar_discover in forum [Archived] Beginning Qt
    Replies: 1
    Last Post: 2011-02-17, 12:58
  3. Install application with existing sqlite database in mass storage in symbian(N-97)...
    By Yogesghpatel in forum [Archived] Nokia Smart Installer for Symbian
    Replies: 2
    Last Post: 2011-01-22, 09:21
  4. Help!How to convert pc db file into symbian db
    By yaohongwang in forum Symbian
    Replies: 2
    Last Post: 2008-06-18, 09:52

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •