Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1
Embedded Database | 125

Array will contain Object instances whose properties match
the names of the columns used in the query. This Array can
be used to iterate over the results of a query.


If the database table that is being queried has no data, or the
statement did not return any data, theSQLResult.dataprop-
erty will benull:


<html>
<head>

<title>Accessing Database Data</title>
<script type="text/javascript" src="AIRAliases.js">
</script>

<script>
var db = null;
var stmt = null

var NONE = -1;
var CREATE_SCHEMA = 0;
var SELECT_DATA = 1;

var state = NONE;

function doDbOpen( event )
{
stmt =new air.SQLStatement();
stmt.addEventListener( air.SQLErrorEvent.ERROR,
doStmtError );
stmt.addEventListener( air.SQLEvent.RESULT,
doStmtResult );

stmt.sqlConnection = db;
stmt.text = "CREATE TABLE IF NOT EXISTS contact ( " +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"first TEXT, " +
"last TEXT )";

state = CREATE_SCHEMA;
stmt.execute();
}

function doLoad()
{
Free download pdf