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. Database Question/Help
Forum Updated to NodeBB v4.3 + New Features

Database Question/Help

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 2.8k 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.
  • L Offline
    L Offline
    lexan
    wrote on 3 Oct 2011, 15:30 last edited by
    #1

    Hi everyone can you help me out??

    @function loadDatabase()
    {
    if (db)
    return;

    db = openDatabaseSync("Sipnayan", "1.0", "Sipnayan", 1000000);
    
    if (!db)
        return;
    
    var rs;
    db.transaction(function(tx) {
        tx.executeSql('CREATE TABLE IF NOT EXISTS levels(level INT, date DATETIME)');
        rs = tx.executeSql('SELECT * FROM levels ORDER BY level DESC LIMIT 1');
    });
    
    if (rs.rows.length > 0) {
        var record = rs.rows.item(0);
        scene.level= record.level;
    }
    

    }

    // Update score database
    function saveLevelToDisk()
    {
    if (!db) {
    console.log("Warning: Database is not open");
    return;
    }

    db.transaction(function(tx) {
        tx.executeSql("INSERT INTO levels VALUES(?, date('now'))", [scene.level]);
    });
    

    }@

    **im having a problem here when i compile and run my app.. there's an error on this line

    @db.transaction(function(tx) {
    tx.executeSql("INSERT INTO levels VALUES(?, date('now'))", [scene.level]);
    });@

    error: db.transaction is not a function
    how can i solve this??

    and i wanna ask.. i want to insert 4 values? how will i do that?? is it like this?

    @tx.executeSql("INSERT INTO levels VALUES(?,?,?, date('now'))", [scene.username,select.area,option.stage]);@

    and how will I be able to call these records in let say i was able to add them in a table.. how would i call the values in the database to a specific qml??

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lexan
      wrote on 9 Oct 2011, 02:36 last edited by
      #2

      Hi everyone, can someone please teach about offline storage?? im having a big problem here

      please refer to this thread

      http://developer.qt.nokia.com/forums/viewthread/10311/

      thanks guys

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Eddy
        wrote on 9 Oct 2011, 06:46 last edited by
        #3

        I merged both posts.

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbrasser
          wrote on 12 Oct 2011, 04:19 last edited by
          #4

          Where/how is your db variable declared?

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lexan
            wrote on 18 Oct 2011, 11:47 last edited by
            #5

            var db=1

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mbrasser
              wrote on 19 Oct 2011, 00:00 last edited by
              #6

              Have you verified that loadDatabase is running to completion, e.g. that if (db) return; is not returning early (which is what I would expect with var db=1 for the declaration)?

              1 Reply Last reply
              0

              6/6

              19 Oct 2011, 00:00

              • Login

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