Database Question/Help

  • Hi everyone can you help me out??

    @function loadDatabase()
    if (db)

    db = openDatabaseSync("Sipnayan", "1.0", "Sipnayan", 1000000);
    if (!db)
    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");

    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??

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

    please refer to this thread

    thanks guys

  • I merged both posts.

  • Where/how is your db variable declared?

  • var db=1

  • 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)?

Log in to reply