2012-02-14 68 views
9

我得到的數據庫:android中的phonegap undefined。我在phonegap中創建了一些表,併成功創建表後,它給了我數據庫未定義的錯誤。請幫忙。我是手機新手。代碼 -phonegap android數據庫未定義的錯誤?

var db; 
var dbCreated = false; 
document.addEventListener("deviceready", onDeviceReady, false); 
function onDeviceReady() { 
    //alert("In Device Ready..."); 
    db = window.openDatabase("sgpw", "1.0", "PhoneGap Demo", 200000); 
    db.transaction(populateDB, transaction_error, populateDB_success); 
} 
+1

發佈一些代碼... – ghostCoder 2012-02-14 12:09:47

+0

var db; var dbCreated = false; document.addEventListener(「deviceready」,onDeviceReady,false); function onDeviceReady(){ \t // alert(「In Device Ready ...」); db = window.openDatabase(「sgpw」,「1.0」,「PhoneGap Demo」,200000); db.transaction(populateDB,transaction_error,populateDB_success); } – 2012-02-15 12:06:32

+0

嗨,我想執行下面的查詢,我得到錯誤「未定義」...代碼:sqlProposal =「選擇*從建議ORDER BY ID DESC LIMIT 1」; tx.executeSql(sqlProposal,[],getProposal_success);任何想法? – 2012-02-16 09:52:07

回答

2

當手機新手時,我也遇到了同樣的問題。 試試這個,

var db = window.openDatabase("sgpw", "1.0", "PhoneGap Demo", 200000); 

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

function onDeviceReady() { 

db.transaction(populateDB, transaction_error, populateDB_success); 

} 

然後,這將調用populateDB功能。
如果出現錯誤,則會致電transaction_error
如果成功,則會調用populateDB_success函數。

相關問題