2

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

5
  • 1
    Which browser are you using to test that? Be aware that only specific browser had implemented that feature before it was canceled. It seems that html5sql.com is using the Web SQL Database, a local SQL Database that no longer maintained by the W3C: "Beware. This specification is no longer in active maintenance and the Web Applications Working Group does not intend to maintain it further." Commented Nov 14, 2012 at 12:22
  • Solved! Inserted: html5sql.openDatabase("com.dynamicvenues.fairkeyMobile.db","Questionnaire",3*1024*1024); Before html5sql.process() at questionnaire.js... Btw. this is for an Android App I'm building with Phonegap/Cordova Commented Nov 14, 2012 at 12:26
  • Then post that as answer instead of a comment and accept it. "To be crystal clear, it is not merely OK to ask and answer your own question, it is explicitly encouraged." Commented Nov 14, 2012 at 12:29
  • Since I'm new here, I can't answer my own question for the next 8 hours :( Sorry Commented Nov 14, 2012 at 12:31
  • There, you should be able to post your answer now :) Commented Nov 14, 2012 at 13:36

1 Answer 1

1

Solved! Inserted: html5sql.openDatabase("com.dynamicvenues.fairkeyMobile.db","Questionnaire",3*102‌​4*1024); Before html5sql.process() at questionnaire.js

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.