Sql – LIttle problem with Flex and sqlite query

apache-flexsqlite

Just a quick question about a small problem I'm having with a flex app I'm creating.

Its my first time tying to create an app using a local database and I'm getting an error in my query.

             private function emptyrow(eventObj:CloseEvent):void {
            var stmt:SQLStatement = new SQLStatement();

         id = datagrid_id.selectedItem.personid;

               if (eventObj.detail==Alert.OK) {
                stmt.sqlConnection = sqlConn;
                stmt.text = "DELETE FROM person WHERE pers_id=".id;
                stmt.execute();
                retrieveData();
                }
        }

The error message I'm getting is – Access of possibly undefined property id through a reference with static type

any insight to what I'm doing wrong would help. Thanks!

Best Answer

You have to declare the id variable like so

private function emptyrow(eventObj:CloseEvent):void {
    var stmt:SQLStatement = new SQLStatement();

    var id :String = datagrid_id.selectedItem.personid;

    if (eventObj.detail==Alert.OK) {
        stmt.sqlConnection = sqlConn;
        stmt.text = "DELETE FROM person WHERE pers_id=" + id;
        stmt.execute();
        retrieveData();
    }
}

Also notice that string concatenation is + not . in AS

Related Topic