3

I'm trying to use WebSQL using html5rocks example. All goes well until I try to do "SELECT * FROM todo" then there is something not clear to me. Callback returns SQLResultSet without SQLResultSetRowList. Code below I tried in Chrome, Background script (Chrome Extension) and Opera.

Step 1. Opening the database

 db = openDatabase("todo", "1.0", "Todo manager", 5 * 1024 * 1024);

Step 2. Creating a table

 db.transaction(function(tx) {
  tx.executeSql("CREATE TABLE IF NOT EXISTS " +
  "todo(ID INTEGER PRIMARY KEY ASC, todo TEXT, added_on DATETIME)", []);
 });

Step 3. Adding data to a table

 db.transaction(function(tx){
  var addedOn = new Date();
  tx.executeSql("INSERT INTO todo(todo, added_on) VALUES (?,?)",
    ['todo_text1', addedOn]);
 });

Step 4. Selecting data from a table

 db.transaction(function(tx) {
  tx.executeSql("SELECT * FROM todo", [], function(tx, r){console.log(tx, r)},
    function(tx, r){console.log(tx, r)});
 });

Can't figure out where I am wrong.

Makoto
  • 104,088
  • 27
  • 192
  • 230
FFFFFF
  • 99
  • 7
  • 2
    When I run your code, the `SQLResultSetRowList` is still there, you just need to access it with `r.rows`. – Xymostech May 01 '13 at 15:31
  • Hey! Thank you very much Xymostech! I was [misled by console](https://dl.dropboxusercontent.com/u/19793035/websql/select.png), it shows `SQLResultSet` with single property `{rowsAffected: 0}` and I wasn't smart enough to guess where the problem. Thank you! – FFFFFF May 01 '13 at 15:55
  • Which is the question here? – G21 May 28 '13 at 16:43

0 Answers0