I’m having problems doing the Database example from PhoneGap. http://docs.phonegap.com/phonegap_storage_storage.md.html#openDatabase
The Problem is, when i run the example to openDatabase and populates he retrieves me the the Success Alert, but when i try to do the select one it gives me an error:
"Error processing SQL:0"
Is there any issue with databases and the android phone that i don’t know? I’ve tried also in the android’s emulator and i’m keep getting the same issue.
Can you help me?
Here is the javascript code:
Now i have the following code:
document.addEventListener("deviceready", onDeviceReady, false);
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS DEMO');
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
}
function errorCB(err) {
alert("Error processing SQL: " + err.code);
}
function successCB() {
alert("success!");
}
function queryDB(tx) {
tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
}
function querySuccess(tx, results) {
alert("i'm here =)");
}
function querySuccess(tx, results) {
// this will be empty since no rows were inserted.
console.log("Insert ID = " + results.insertId);
// this will be 0 since it is a select statement
console.log("Rows Affected = " + results.rowAffected);
// the number of rows returned by the select statement
console.log("Insert ID = " + results.rows.length);
}
function onDeviceReady() {
$(document).ready(function() {
$('#submit').click(function() {
alert('clicked');
var db = window.openDatabase("test", "1.0", "Test DB", 1000000);
db.transaction(populateDB, errorCB, successCB);
db.transaction(queryDB, errorCB);
})
});
}
And still have the Succes alert when i do the populate transaction but the Alert of the queryDB has the Error processing SQL:0.
Thanks in advance,
Elkas
PS: I’m also using jQuery Mobile
I Forgot to update this question. With Lion 10.7.2 its working perfectly.
Regards,
Elkas