Reputation: 2682
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!
Upvotes: 0
Views: 110
Reputation: 13088
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
Upvotes: 1