Exporting WebSql to csv undefined

gbhnvc

New Member
I'm exporting my table to csv, but it appears undefined...It actually see the data, and give me an table, but it gets undefined...Do you I have to make any coverting to do this? Js code:\[code\] var db = openDatabase("LOGS", "1.0", "SliceFinance Database", 1024); db.transaction(createTbl, errorCB, successCB); function errorCB(err){ alert('Error '+ err.code); } function successCB(){ alert('ok'); exportTbl(); } function createTbl(tx){ //tx.executeSql('DROP TABLE IF EXISTS ENTRIES'); tx.executeSql('CREATE TABLE IF NOT EXISTS ENTRIES (id integer primary key autoincrement, entry TEXT NOT NULL)'); //tx.executeSql('INSERT INTO ENTRIES(entry) VALUES("teste")'); //tx.executeSql('INSERT INTO ENTRIES(entry) VALUES("teste2")'); } exportTbl = function(){ var datahttp://stackoverflow.com/questions/15912078/= ""; db.transaction(function(tx){ tx.executeSql('SELECT * FROM ENTRIES', [], function (tx, results){ var len = results.rows.length, i; for (i = 1; i < len; i++) { data += results.rows.item(i).itemno + "," + results.rows.item(i).quantity + "\n"; } window.location='data:text/csv;charset=utf8,' + encodeURIComponent(data); }); });};\[/code\]
 
Back
Top