2015-06-29 69 views
0

我正在運行chrome 43.0。在控制檯我正在運行下面的命令:數據庫語句在Google Chrome中不起作用

>> var db1 = openDatabase('testDB', '', 'my first database', 2 * 1024 * 1024, function(d){console.log(d);}); 

    >> undefined 

    >> db1.transaction(function (tx) { 
     console.log("....................."); 
     console.log(tx.executeSql("INSERT INTO fileLog (fileName, bucketName) VALUES ('123','synergies')")); 
    }); 

    >> undefined 
    ..................... 
     undefined 

問題是它沒有插入任何數據在fileLog表。

+0

選擇價值觀的問題是,有沒有錯誤回電話。 –

回答

0

您必須插入值之前把它視爲如下創建表fileLog:

db1.transaction(function (tx) { 
tx.executeSql('CREATE TABLE IF NOT EXISTS fileLog (fileName,bucketName)'); }); 

而且你可以從它

db1.transaction(function (tx) { 
     tx.executeSql('SELECT * FROM fileLog ', [], function (tx, results) { 
    for (var i = 0; i < results.rows.length; i++){ 
     console.log(results.rows.item(i).fileName," ",results.rows.item(i).bucketName); 
     } 

    }, null); 
    });