我正在使用带有表用户(名字、姓氏、密码)的 SQLite 数据库开发一个带有 FLEX 的应用程序,在此表中插入数据没问题,但是当我想选择数据时,我得到了同样的错误(无法访问属性或方法空对象引用。)
我的选择代码:
selectStmt = new SQLStatement;
selectStmt.sqlConnection = conn;
selectStmt.text = "SELECT firstName FROM users";
selectStmt.addEventListener(SQLEvent.RESULT, resultHandler);
selectStmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
selectStmt.execute();
我的 resultHandler 代码:
public function resultHandler(event:SQLEvent):void
{
var result:SQLResult = selectStmt.getResult();
if(result == null)
{
lblFeedback.text = "nul";
}
else
{
var numResults:int = result.data.length;
for (var i:int = 0; i < numResults; i++)
{
var row:Object = result.data[i];
var output:String = "iD: " + row.itemId;
output += "; fName: " + row.firstName;
output += "; lName: " + row.lastName;
output += "; passwd: " + row.password;
lblFeedback.text = output;
}
}
}
var 结果不为空,但在执行时似乎出错了: var numResults:int = result.data.length;
有人能帮我吗?现在已经找了一段时间了,这真的很令人沮丧!
提前致谢!