Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Unable to use the existing database on symbian device?

Unable to use the existing database on symbian device?

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    noormuhammad
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DanSiddiqui
      wrote on last edited by
      #2

      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);

      }

      1 Reply Last reply
      0
      • N Offline
        N Offline
        noormuhammad
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mica_damian
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved