在同一视图中将SQLite查询结果加载到textarea中

时间:2011-02-27 19:52:11

标签: flex sqlite actionscript

如何将SQLite查询的结果放入textarea?

想法是用户按下“下一步”按钮,然后textarea显示下一条记录中下一个文本值的文本。我相信我正确地传递了值,但是当我使用trace()时,值会变为未定义。

我做错了什么?

protected function button6_clickHandler(event:MouseEvent):void  // pushed --> button 
{
    var cardNumber:int = parseInt(cardNumberLabel.text);
    var newcardid:int = cardNumber+1;
    var sqlresult:SQLResult = stmt.getResult();
    stmt.sqlConnection = conn;
    conn.open(File.applicationStorageDirectory.resolvePath("FlashCards.db"));
    stmt.text = "SELECT * FROM cardItems WHERE id  = ?";
    stmt.parameters[0] = newcardid;
    stmt.execute();
    trace(sqlresult.data);  // value = [object Object]
    stext1.text = sqlresult.data.cSide1;
    trace(sqlresult.data.cSide1);  // value = 'undefined'
    cardNumberLabel.text = sqlresult.data.id;
    trace(sqlresult.data.id);  // value = 'undefined'
    conn.close();
    moveEffectRPart1.play();
    moveEffectRPart1.addEventListener(EffectEvent.EFFECT_END, nextMoveRPart);
}

编辑:工作代码 *

    private function nextMoveRPart(event:EffectEvent):void
        {
            var cardNumber:int = parseInt(cardNumberLabel.text);

            stmt.sqlConnection = conn;
            conn.open(File.applicationStorageDirectory.resolvePath("FlashCards.db"));
            stmt.text = "SELECT * FROM cardItems WHERE id = ?" + "AND id <= MAX(id)";
            stmt.parameters[0] = cardNumber+1;
            stmt.addEventListener(SQLEvent.RESULT, resultHandlerPrev);
            stmt.execute();
            conn.close();
            moveEffectRPart2.play();
        }
        function resultHandlerNext(event:SQLEvent):void  // result handler next
        {
            var result:SQLResult = stmt.getResult();
            var numResults:int = result.data.length;
            for(var i:int = 0; i < numResults; i++)
            {
                var row:Object = result.data[i];
                stext1.text = row.cSide1;
                stext2.text = row.cSide2;
                cardNumberLabel.text = row.id;

            }
        }

0 个答案:

没有答案