javascript - Error processing SQL:0 PhoneGap SQL - Stack Overflow

Im trying out and copied code from here:To succeed with a sample I'm working on just to learn t

Im trying out and copied code from here: / To succeed with a sample I'm working on just to learn this. I have a link to my plete index.html on pastebin.

Please, correct me and also help me finding this errror.

Link to Pastebin here

Im trying out and copied code from here: http://luthfihariz.wordpress./2011/10/23/android-sqlite-phonegap-jquerymobile/ To succeed with a sample I'm working on just to learn this. I have a link to my plete index.html on pastebin.

Please, correct me and also help me finding this errror.

Link to Pastebin here

Share Improve this question asked Dec 20, 2012 at 14:45 JackJack 3,6807 gold badges47 silver badges69 bronze badges 3
  • Does your error indicate which line is throwing that error? Could you also try moving the opendatabase call into the onDeviceReady method? – Nick Roth Commented Dec 20, 2012 at 15:07
  • I get an alert which says at first "success!" and then I press OK, after that another one pops up. That one says "Error processing SQL: 0". – Jack Commented Dec 20, 2012 at 15:42
  • I gave your code a closer look and have a few ideas, but none of them I can definitively say are the root cause. I think the best thing you can do for now is add some more logging to determine which line is causing you to enter your errorCB function. Once you can at least understand how it got to your error function we can more accurately debug. – Nick Roth Commented Dec 20, 2012 at 16:13
Add a ment  | 

1 Answer 1

Reset to default 5

I didn't have a lot of time, and it's soon xmas :) But.. :) I did write you a working example with your code as a starter.

Using Cordova version 2.2.0 Using PhoneGap to pile I did test it on an android device I did change some things here and there, but I used the code frome here as a reference.

document.addEventListener("deviceready", onDeviceReady, false);

var db = "";

function populateDB(tx) {
    tx.executeSql('DROP TABLE IF EXISTS SoccerPlayer');
    tx.executeSql('CREATE TABLE IF NOT EXISTS SoccerPlayer (Name TEXT NOT NULL, Club TEXT NOT NULL)');
    tx.executeSql('INSERT INTO SoccerPlayer(Name,Club) VALUES ("Alexandre Pato", "AC Milan")');
    tx.executeSql('INSERT INTO SoccerPlayer(Name,Club) VALUES ("Van Persie", "Arsenal")');
}

function queryDB(tx) {
    tx.executeSql('SELECT * FROM SoccerPlayer', [], querySuccess, errorCB);
}


function querySuccess(tx,result){
        var playerlist = document.getElementById("SoccerPlayerList");
        var players = "";
        alert("The show is on");
        var len = result.rows.length;
        for (var i=0; i<len; i++){
            alert(result.rows.item(i).Name + result.rows.item(i).Club);
            players = players + '<li><a href="#"><p class="record">'+result.rows.item(i).Name+'</p><p class="small">Club '+result.rows.item(i).Club+'</p></a></li>';
        }   

        playerlist.innerHTML = players;
        $("#SoccerPlayerList").listview("refresh");
}


function errorCB(err) {
    alert("Error processing SQL: "+err.code);
}


function successCB() {
    db.transaction(queryDB, errorCB);
}


function onDeviceReady() {
    db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
    db.transaction(populateDB, errorCB, successCB);
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745564977a4633339.html

相关推荐

  • javascript - Error processing SQL:0 PhoneGap SQL - Stack Overflow

    Im trying out and copied code from here:To succeed with a sample I'm working on just to learn t

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信