2012-12-13 62 views
0

我使用phoneagap框架進行APP開發。 插入查詢中的PhoneGap:PhoneGap插入查詢+不工作

tx.executeSql('insert into "'+gAppConfig.configTable+'" (key , value) values(uniqueId,"'+uniqueId+'"),(serverURL,"'+serverURL+'")' , querySuccess, errorQuery); 

這不是工作,誰能告訴我什麼可能是錯誤的。謝謝。

回答

1

我想你已經在數據庫中創建了一個表,並且你已經用2列「id」&「serverURL」將它命名爲「tablename」;其中「id」是主鍵。

試試這個:

Iquery = "INSERT INTO 'tableName' VALUES(null, "+serverURL+");"; 
    tx.executeSql(
     Iquery, 
     null, 
     function(){ /* to do on success, or you may just set it as "null" */}, 
     function(){ /* to do on error, or you may just set it as "null" */}); 

,或者你可以試試這個:

tx.executeSql("INSERT INTO tableName(id, serverURL) VALUES (?,?)", 
     [null, serverURL], // these are the variables to insert 
     function(){ /* to do on success, or you may just set it as "null" */}, 
     function(){ /* to do on fail, or you may just set it as "null" */}); 

您可以參考原documentation of cordova以獲得更多信息。