Does anyone know why I’m getting this error on the code below?
Scene 1, Layer ‘Layer 1’, Frame 1, Line 44 1119: Access of possibly undefined property result through a reference with static type flash.data:SQLStatement.
import flash.data.SQLResult;
import flash.filesystem.File;
import flash.data.SQLStatement;
import flash.data.SQLConnection;
import flash.data.SQLColumnSchema;
import flash.data.SQLTableSchema;
import flash.data.SQLSchemaResult;
import flash.events.SQLEvent;
import flash.events.SQLErrorEvent;
import flash.events.MouseEvent;
import fl.data.DataProvider;
var connection:SQLConnection;
function onCreationComplete():void
{
var file:File = File.applicationStorageDirectory.resolvePath("contacts.db");
connection = new SQLConnection();
connection.open( file );
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "CREATE TABLE IF NOT EXISTS CONTACTS (CONTACT_ID INTERGER PRIMARY KEY AUTOINCREMENT, FIRST_NAME TEXT, LAST_NAME TEXT, EMAIL TEXT)";
statement.execute();
refreshContacts();
}
function refreshContacts():void
{
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "SELECT * FROM CONTACTS";
statement.execute();
contacts.dataProvider = statement.getResult().data; //<-- ERROR HERE
}
function addContact():void
{
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "INSERT INTO CONTACTS (FRIST_NAME, LAST_NAME, EMAIL) VALUES (?, ?, ? )";
statement.parameters[0] = firstName.text;
statement.parameters[1] = lastName.text;
statement.parameters[2] = email.text;
statement.execute();
refreshContacts();
}
function deleteContact():void
{
var statement:SQLStatement = new SQLStatement();
statement.sqlConnection = connection;
statement.text = "DELETE FROM CONTACTS WHERE CONTACT_ID = ?";
statement.parameters[0] = contacts.selectedItem.CONTACT_ID;
statement.execute();
refreshContacts();
}