Unable to use the existing database on symbian device?



  • I am developing the application for symbian device. I am using these lines to connect with database.

    @db = openDatabaseSync("mydatabase", "1.0", "mydatabase", 1000000);@

    I changed the data storage path like this:

    @
    QDeclarativeEngine engine;
    engine.setOfflineStoragePath(QString("E:\"));
    @

    When i deploy the application in debugging mode on device. It creates the folder "Databases" in "E:" drive with .ini file in it but it does not create the database file(.sqlite).

    At this line
    @tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');@

    It gives me this error

    @
    [Qt Message] QSqlQuery::prepare: database not open
    [Qt Message] file:///C:/Private/e15a05d0/qml/NokiaApp/jscript.js:15: Error:
    @

    When i googled it, I found that it would be created at the path something like this C:\Private\e15a05d0" . I am unable to find the private folder in C drive. Its hidden. How can i access that? If i create the new database at default path, then i am unable to locate those database files on device.

    I want to use existing database. There are hundreds of records in my database. How can i make sure that deployment process should deploy the same database which i created on windows.

    I didn't find any help in documentation. Can anyone resolve this issue?

    Thanks in advance.



  • I have developed project using following code , i think this will help u .My .sqllite file exist on the Project's folder: i added the the following line on .pro file.

    addFiles.sources = Name.sqlite
    addFiles.path = .
    DEPLOYMENT += addFiles

    these lines copy sqllite file on the device.

    and for access this database (Name.sqllite) file please use following code:

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("Name.sqlite");
    if(!db.isOpen())
    {

        QMessageBox::critical(0, qApp->tr("Cannot open database"),
                              qApp->tr("Unable to establish a database connection.\n"
                                       "This example needs SQLite support. Please read "
                                       "the Qt SQL driver documentation for information how "
                                       "to build it.\n\n"
                                       "Click Cancel to exit."), QMessageBox::Cancel);
    

    }
    else
    {
    QMessageBox::critical(0, qApp->tr("open database"),
    qApp->tr("database connection opened."), QMessageBox::Ok);

    }



  • Thanks for the response.

    I am building the app in QML + Javascript. My folder hierarchy is this

    @-QML
    ----|qml/NokiaApp
    ----------|main.qml
    -Otherfiles
    ----|qml
    -------|NokiaApp
    ------------|Script.js
    -------|OfflineStorage/Databases
    ------------|Database.sqlite@

    I used this code

    @addFiles.sources = Database.sqlite
    addFiles.path = qml/OfflineStorage
    DEPLOYMENT += addFiles@

    At this change, i received error Database.sqlite not found

    I even tried this

    @addFiles.sources = /qml/OfflineStorage/Databases/Database.sqlite
    addFiles.path = qml/OfflineStorage/Databases
    DEPLOYMENT += addFiles@

    At this change, it didn't give me any error of file not found but it gave the same old error

    @[Qt Message] QSqlQuery::prepare: database not open@

    I can't use C++ code because i am bound to use only QML + Javascript.

    Can you suggest anything?

    Thanks



  • Maybe it iis problem with your path in main.cpp because on my nokia x6 when i don't change path it is work !!you must use default path and it work .When you have any question please contact me. and i help you
    Best regards Damian.


Log in to reply
 

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