1
<script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, false);
var db;
//function will be called when device ready
function onDeviceReady() {
db = window.openDatabase("Dummy_DB", "1.0", "Just a Dummy DB", 200000); //will create database Dummy_DB or open it
db.transaction(populateDB, errorCB, successCB);
}
//create table and insert some record
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS SoccerPlayer');
tx.executeSql('CREATE TABLE IF NOT EXISTS SoccerPlayer (id integer primary key, Name text, Club text)');
tx.executeSql('INSERT INTO SoccerPlayer(Name,Club) VALUES ("Alexandre Pato", "AC Milan")');
tx.executeSql('INSERT INTO SoccerPlayer(Name,Club) VALUES ("Van Persie", "Arsenal")');
}
//function will be called when an error occurred
function errorCB(err) {
alert("Error processing SQL: " + err.code);
}
//function will be called when process succeed
function successCB() {
alert("success!");
db.transaction(queryDB, errorCB, successCB);
}
function queryDB(tx) {
tx.executeSql('SELECT Name,Club FROM SoccerPlayer', [], querySuccess);
}
function querySuccess(tx, result) {
$('#SoccerPlayerList').empty();
$.each(result.rows, function (index) {
var row = result.rows.item(index);
$('#SoccerPlayerList').append('<li><a href="#"><h3 class="ui-li-heading">' + row['Name'] + '</h3><p class="ui-li-desc">Club ' + row['Club'] + '</p></a></li>');
});
$('#SoccerPlayerList').listview();
}
</script>
我已創建例如商店,並使用PhoneGap的,但第一個警報更迭,然後拋出後誤差0 retrive數據庫。請幫助我,我在PhoneGap的是新..
<script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, false);
var db;
//function will be called when device ready
function onDeviceReady() {
db = window.openDatabase("Dummy_DB", "1.0", "Just a Dummy DB", 200000); //will create database Dummy_DB or open it
db.transaction(populateDB, errorCB, successCB);
}
//create table and insert some record
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS SoccerPlayer');
tx.executeSql('CREATE TABLE IF NOT EXISTS SoccerPlayer (id integer primary key, Name text, Club text)');
tx.executeSql('INSERT INTO SoccerPlayer(Name,Club) VALUES ("Alexandre Pato", "AC Milan")');
tx.executeSql('INSERT INTO SoccerPlayer(Name,Club) VALUES ("Van Persie", "Arsenal")');
}
//function will be called when an error occurred
function errorCB(err) {
alert("Error processing SQL: " + err.code);
}
//function will be called when process succeed
function successCB() {
alert("success!");
db.transaction(queryDB, errorCB, successCB);
}
function queryDB(tx) {
tx.executeSql('SELECT Name,Club FROM SoccerPlayer', [], querySuccess);
}
function querySuccess(tx, result) {
$('#SoccerPlayerList').empty();
$.each(result.rows, function (index) {
var row = result.rows.item(index);
$('#SoccerPlayerList').append('<li><a href="#"><h3 class="ui-li-heading">' + row['Name'] + '</h3><p class="ui-li-desc">Club ' + row['Club'] + '</p></a></li>');
});
$('#SoccerPlayerList').listview();
}
</script>
'Sqlite' - 錯誤代碼0 - >確定。 – 2014-11-04 05:35:15
是的,先生的錯誤代碼0 – 2014-11-04 05:40:41
我有同樣的問題,試圖找到任何答案! – 2015-03-28 01:01:15