Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1

122 | Chapter 4: AIR Mini-Cookbook


"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"first TEXT, " +
"last TEXT )";

state = CREATE_SCHEMA;
stmt.execute();
}

function doLoad()
{
var file =
air.File.applicationResourceDirectory.resolve( "crm.db" );

db =new air.SQLConnection();
db.addEventListener( air.SQLEvent.OPEN, doDbOpen );
db.open( file, true );

document.getElementById( "btnSave" ).
addEventListener( "click", doSave );
}

function doSave()
{
var first = document.getElementById( "txtFirst" ).value;
var last = document.getElementById( "txtLast" ).value;

stmt.text = "INSERT INTO contact VALUES ( " +
"NULL, " +
"’" + first + "’, " +
"’" + last + "’ )";

state = INSERT_DATA;
stmt.execute();
}

function doStmtResult( event )
{
switch( state )
{
case CREATE_SCHEMA:
alert( "The database table has been created." );
state = NONE;

break;
Free download pdf