dimanche 3 mai 2015

Receiving Data from SQLITE Select with Javascript

I am encountering a problem with the select of SQLite.

I can read out the data but i do not know how to parse the values to a var so i can work with it. All i can do is log ist. So far i have two approaches. The first is not working at all.

    var readPath = function(){
        var newPath = '';
        var docPath = '';

        console.log("los gehts");

        db.transaction(function(tx) {

            tx.executeSql('Select Path AS path from TProject where Name = "timeBroMain"', [], function(tx, results){
                for (var i=0; i < results.rows.length; i++){
                    console.log(row.path);
                    row = results.rows.item(i);
                    retrieveData(row.path);
                }
            });
        });
    }
    function retrieveData(path) {
        alert(path);
    }
    readPath();

With the second approach I can log the items but not obtain them.

        db.serialize(function() {
            if(!exists) {
                alert("Table not accesed");
            }
            db.each("Select Path AS path from TProject where Name = 'timeBroMain'", function(err, row) {
                console.log(row.path);
                docPath = row.path;
            });
            alert(results.rows.item(0).text);
            newPath = docPath + '/' + name;
        });

How can the Data be processed? I would like to ad the value from the databse to another string and write it back to the db.

Aucun commentaire:

Enregistrer un commentaire