WinJsApps : JSSqliteDB.dll, SQLiteDatabase for WinJsApps

Directory Structure :

WinJSApps :
		- dll :
			- sqlite :
				-JSSqliteDB.dll
				- ...
				- ...
				- ...
		- WinJsApps.exe
		- WinJsApps.exe.config 
		- ...
		- ...

Load DLL object from javascript

var sqlitedll =  window.external.loadDll("sqlite/JSSqliteDB.dll");

Sqlite database connection

Get Sqlite database connection

 var curdir  = window.external.getCurrentDirectory().replace(/\\/g,"/");  
 var sqlitedll =  window.external.loadDll("sqlite/JSSqliteDB.dll");
 var dbcon = sqlitedll.getCon(curdir + "/dmydb.db");

SqliteCommandools

To execute query the command tools must created from connection with sqlite query as parameter, for example how to get SqliteCommandTools

var query = "SELECT * FROM TableBarang";
	var command = dbcon.createCommand(query);

the next, “execute” or “executeReader” or “executeReaderAsyn” can be call from the command tools

execute (void)
command.execute() is void, no return,. specifically using for query that no need a result, like create, insert, update, delete etc.

 
	command.execute();

executeReader (String)
executeReader will return json string (synchronous)

 
	var jsonstring = command.executeReader();

executeReaderAsync (void)
Call executeReader with asynchronous method, this void need javascript object with function “result” as member, the “result” will call after executeReader finished, and string result will send to the “result” function as parameters.

 
var command = dbcon.createCommand("SELECT * FROM TableBarang");		 
	command.executeReadAsync({
		result : function(json){
			alert(json);
		}
	});	

Download WinJsApps here :http://www.ttsberita.com/2016/03/winjsapps-windows-apps-dengan-javascript-dan-html.html

Video