126 | Chapter 4: AIR Mini-Cookbook
var file =
air.File.applicationResourceDirectory.resolve( "crm.db" );
db =new air.SQLConnection();
db.addEventListener( air.SQLEvent.OPEN, doDbOpen );
db.open( file, true );
}
function doStmtResult( event )
{
var elem = null;
var result = null;
switch( state )
case CREATE_SCHEMA:
stmt.text = "SELECT * FROM contact";
state = SELECT_DATA;
stmt.execute();
break;
case SELECT_DATA:
result = stmt.getResult();
if( result.data != null )
{
for(var c = 0; c < result.data.length; c++ )
{
elem = document.createElement( "div" );
elem.innerText = result.data[c].first +
" " + result.data[c].last;
document.body.appendChild( elem );
}
}
state = NONE;
break;
default:
state = NONE;
break;
}
}