How to use SQLite in Firefox Extension (XUL files) with Javascript source? -


i wanted write firefox extension creates sqlite database, puts records in it. however, have error during running statement.

here's xul file:

<?xml version="1.0"?> <overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">   <script type="application/x-javascript" src="chrome://sqlitetry/content/sqlitetry.js"/>   <statusbar id="status-bar">     <statusbarpanel id="my-panel" label="welcome sqlite try 1.0b."  />   </statusbar>   <html:div id="status">   </html:div> </overlay> 

this javascript plugin tries create database , records:

components.utils.import("resource://gre/modules/services.jsm"); components.utils.import("resource://gre/modules/fileutils.jsm")  var dbfile = fileutils.getfile("profd", ["test.sqlite"]); var dbservice = components.classes["@mozilla.org/storage/service;1"]. getservice(components.interfaces.mozistorageservice); var dbconnection; console.log("connect...") dbconnection = dbservice.opendatabase(dbfile); console.log("\tok") var statement = dbconnection.createstatement("select * mytest"); var res = statement.executestep(); 

but there error in browser console this:

ns_error_failure: component returned failure code: 0x80004005 (ns_error_failure) [mozistorageconnection.createstatement]

here's complete source of extension script: http://speedy.sh/4nhsf/source4.xpi

could please, problem is?

well, didn't create mytest table, select statement fails. try

... dbconnection = dbservice.opendatabase(dbfile); console.log("\tok") dbconnection.createtable("mytest", "foo integer, bar string"); dbconnection.executesimplesql("insert mytest (foo,bar) values (1,'test')") ... 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -