0 Replies Latest reply on Jun 19, 2010 6:38 AM by arul@indiaglitz

    Retriving Data From SQL LITE and return it

    arul@indiaglitz

      Hi,
      I am using FLEX 3.5 SQL LITE, and code is
      dbase.as
      ~~~~~~
      var fieldarray = new Array("name","age")
      datahand = new dataHand();
      datahand.getData("sometable",fieldarray);

       

      dataHand.as
      ~~~~~~~~~~~
      public function getData(table, field){
          selectStmt=new SQLStatement();
          selectStmt.sqlConnection=conn;
                 
          var sql:String="SELECT ";
                 
          for(var i=0;i<field.length;i++){   
              var string = " "+field[i]+",";   
              sql+=string;
          }
                 
          sql  = sql.substr(0,sql.length-1);
          sql+=" FROM "+table;
                 
          trace("GET DATA SQL:"+sql);
                 
          selectStmt.text=sql;

       

          selectStmt.addEventListener(SQLEvent.RESULT, selectResult);
          selectStmt.addEventListener(SQLErrorEvent.ERROR, selectError);

       

          selectStmt.execute();
      }

       

      private function selectResult(event:SQLEvent):void {
          selectStmt.removeEventListener(SQLEvent.RESULT, selectResult);
          selectStmt.removeEventListener(SQLErrorEvent.ERROR, selectError);

       

          var result:SQLResult=selectStmt.getResult();
          if(result.data != null){
              trace(result.data);
          }else{
              trace("data empty null");
          }
      }

       

      but what  i want is getData must be able to return the data after successful result
      like
      var _data = datahand.getData("sometable",fieldarray);
      where _data is data from table

       

      is there any way to work out this, Thanks a lot.