Skip navigation
Currently Being Moderated

sqlite db query to  text fields question

Sep 19, 2013 11:02 AM

I have a search query which I can send the data to a list but how do I send the data to text fields?
for example I search in a myTable with 4 columns: id, item1, item2, item3, this is the code:I


private function cSearch():void {
    stmt.sqlConnection = this.isDbConnected(sqlConn);
    var sql:String  = "SELECT * FROM myTable WHERE (myTable.item1) LIKE '%' ||@item1|| '%' ";
    stmt.parameters["@item1"] = searchInput.text;
    stmt.text = sql;
    stmt.addEventListener(SQLErrorEvent.ERROR, sqlError);
    stmt.addEventListener(SQLEvent.RESULT, selectResult);


if I want to display the data to a list I will use this code:


private function selectResult(res:SQLEvent):void {
    var data:Array = stmt.getResult().data;
    cList = new ArrayCollection();
    if (data){
        for (var d:int=0;d<=data.length-1;d++) {
            cList.addItem({id:data[d].id,item1:data[d].item1,item2:data[d].item2t ,item3:data[d].item3});
    }else {
        trace("no available records");
private function displayLData(item:Object):String {
    return + ".  \t" + item.item1+ "   \t" + item.item2 + "   \t" + item.item3;


and the list will be:


<s:List id="myList"  width="100%" height="100%" dataProvider="{cList}" labelFunction="displayLData" > </s:list>


so it works, data is display


But what about if I want to send the data to a 4 diferent text fields?


I tried this but it doesn't work


private function selectResult(event:SQLEvent):void {
    var searchRes:SQLResult = stmt.getResult();
    cList = new ArrayCollection(;
        if ( != null) {
           idSt =;
            item1St =;
            item2St =;
            item3St =;


any help ?

  • Currently Being Moderated
    Sep 20, 2013 6:55 AM   in reply to pao1011

    you can use the same code as your first example (list) but instead of pushing the data to the arrayCollection, put the results in the appropriate text fields.

    For this to work, you have to access the textInput objects


    - Suppose your textInput are grouped in a group with id 'tfGroup's

    - suppose your textInput id's are tf0, tf1, etc...s


    for (var d:int=0;d<=data.length-1;d++) {


                var tf:TextInput = tfGroup["tf" + d];

              tf.text = whateverYouWantToPutThere;

                //cList.addItem({id:data[d].id,item1:data[d].item1,item2:data[d].item 2t ,item3:data[d].item3});



    I haven't test this but it should work.


    Another solution might be to bind your textInput text properties to an item in your cList collection.


    <TextInput id="tf0" text = {cList.getItemAt(0)}/>

    this way you can still populate the cList in your sql function.

    Be sure to declare cList as [Bindable] thought


    hope this helps



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points