Flex App Sqlite Select语句返回[object Object]

时间:2014-12-22 14:44:33

标签: sqlite actionscript-3 flex actionscript

我正在尝试根据下面的SQL Select语句使用我的SQLite数据库中AthleticsURL字段的值填充StageWebview.loadURL。当我在sqlAthResult函数中跟踪变量时,我得到:

结果:[object Object]

输出:null

(空)

有关如何返回AthleticsURL值的任何建议? AthleticsURL是一个String

private function athleticsData():void
{
stmts.sqlConnection = this.isDbConnected(conn);
stmts.text = "SELECT AthleticsURL FROM DistrictSchools where AthleticsFavs == 1";
stmts.addEventListener(SQLErrorEvent.ERROR, sqlError);
stmts.addEventListener(SQLEvent.RESULT, sqlAthResult);
stmts.execute();
trace("Row requested @athleticsData");
}

public function sqlAthResult(res:SQLEvent):void{
var result:Array = stmts.getResult().data;
var output:String = result.AthleticsURL;
trace("result:" +result);
trace("output: " +output);
trace(ObjectUtil.toString(result.data));    
}

2 个答案:

答案 0 :(得分:0)

尝试以下,它会给你结果:

sqlConnectionSync = new SQLConnection();//create a connection object
sqlConnectionSync.open(file, SQLMode.READ);

private function athleticsData():void
{
 var stmts:SQLStatement = new SQLStatement(); //create the insert statement
 stmts.sqlConnection = sqlConnectionSync; //set the connection
 stmts.addEventListener( SQLEvent.RESULT, sendQueryResult ); 
 stmts.text = "SELECT AthleticsURL FROM DistrictSchools where AthleticsFavs == 1";
 stmts.execute();
}

public function sqlAthResult(res:SQLEvent):void
{
    var res:SQLResult = SQLStatement(event.currentTarget).getResult();
    var result: ArrayCollection = new ArrayCollection( res.data ); 
    var output:String = result.AthleticsURL;
    trace("result:" +result);
    trace("output: " +output);
    trace(ObjectUtil.toString(result.data));    
}

答案 1 :(得分:0)

我想出了一个解决方案,想在这里发帖。 var网站从我的SQLite表中返回http://字符串。

var website:String = AthList[0].AthleticsURL; 
trace("website: " + website);
webView.stage = this.stage;
webView.viewPort = new Rectangle(0, navigator.actionBar.height*scaleFactor, FlexGlobals.topLevelApplication.width*scaleFactor,(FlexGlobals.topLevelApplication.height*.9-navigator.actionBar.height)*scaleFactor);
            webView.loadURL(website);