views:

21

answers:

1

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!

+1  A: 

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

Matti
thanks for the help.
Adam