Javascript 数据库语句在google chrome中不起作用
我正在运行chromeJavascript 数据库语句在google chrome中不起作用,javascript,sqlite,google-chrome,opendatabase,Javascript,Sqlite,Google Chrome,Opendatabase,我正在运行chrome43.0。在控制台中,我运行以下命令: >> var db1 = openDatabase('testDB', '', 'my first database', 2 * 1024 * 1024, function(d){console.log(d);}); >> undefined >> db1.transaction(function (tx) { console.log(".............
43.0
。在控制台中,我运行以下命令:
>> 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
表中插入任何数据。必须先创建表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);
});
db1.事务(函数(tx){
tx.executeSql('SELECT*FROM fileLog',[],函数(tx,results){
对于(var i=0;i
问题在于没有错误回调。