I'm using html5sql.com for doing html5 DB stuff :o) - Really a great module...
However, I got stuck!
At my index.html/index.js I create my database and tables in it.
try { html5sql.openDatabase("com.dynamicvenues.fairkeyMobile.db","Questionnaire",3*1024*1024); html5sql.process( [ "CREATE TABLE IF NOT EXISTS Questionnaire (uid INTEGER, json TEXT, hash TEXT);", "CREATE TABLE IF NOT EXISTS Answers (id INTEGER PRIMARY KEY, visitor_id TEXT, json TEXT);" ], function(){ console.log("Success Creating Tables"); }, function(error, statement){ console.error("Error: " + error.message + " when processing " + statement); } ) } catch(error) { alert("Database create failed: "+error.message); } And further in the same page I populate one table with data:
jQuery.get(serverHttp+"json.php?exhibitorID="+exhibitorID, function(data){ var html = $(data).map(function() { return $(this).html(); }); var jsonStr = html[0]; var exhibitorID = html[1]; var hashStr = html[2]; var SQL = "INSERT INTO Questionnaire (uid, json, hash) VALUES ("+exhibitorID+",'"+jsonStr+"','"+hashStr+"')"; try { html5sql.process(SQL, function(){ console.log('Inserted 1 row!'); }, function(){ console.error("Error: " + error.message + " when processing " + statement); } ) } catch(error) { alert("Query failed: "+error); } Now, in a different page called questionnaire.html/questionnaire.js I'm trying to retrieve the data I stored in the table Questionnaire.
html5sql.process( ["SELECT * FROM Questionnaire;"], function(transaction, results, rowsArray){ for(var i = 0; i < rowsArray.length; i++){ var uid = rowsArray[i].uid; var json = rowsArray[i].json; var hash = rowsArray[i].hash; console.log("Retrieved rows: "+uid+" - "+json+" "+hash); } console.log("Done selecting data"); }, function(error, statement){ console.error(error.message+" Occured while processing: "+statement); } ); What am I doing wrong???
Regards, Daniel