×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    9

    Qml and database retrieve an int

    Hello i need that my game save in a offline db the scores and show only the first(the highest).
    I write this js function:
    Code:
    function saveHighScore(punti) {
    
            var db = openDatabaseSync("VSpeedScore", "1.0", "Local VSpeed Score", 1000);
            var dataStr = "INSERT INTO Scores VALUES(?)";
            var data = punti;
            db.transaction(function(tx) {
                tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(score NUMBER)');
                tx.executeSql(dataStr, data);
    
                var rs = tx.executeSql('SELECT * FROM Scores ORDER BY score desc LIMIT 1');
                var r =  rs.rows.item(0).score
                
                return r
            });
    
    
        }
    Then the qml code:
    Code:
    Pulsante{
            id: bt1
            property int multi: 1
            property int highscore: 0
            punti: 0
    [...]
    bt1.highscore = saveHighScore(bt1.punti)
    I need an int.

    The error is:
    Cannot assign [undefined] to int

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814

    Re: Qml and database retrieve an int

    according to sqlite documentation, you should be creating an INTEGER column, not a NUMBER one.

Similar Threads

  1. QML Contacts and Importing an individual from a list
    By TejWC in forum [Archived] Qt Mobility Project
    Replies: 1
    Last Post: 2011-05-12, 00:51
  2. Best approach to retrieve values from a QML Modal dialog
    By _MrData_ in forum [Archived] Qt Quick
    Replies: 2
    Last Post: 2011-05-03, 19:17
  3. SQLite database and QML
    By angusr in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2011-03-29, 16:28
  4. How to retrieve vars from QML components
    By KevinSharp in forum [Archived] Qt Quick
    Replies: 4
    Last Post: 2011-01-25, 16:58
  5. Replies: 5
    Last Post: 2010-12-10, 11:03

Posting Permissions

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