2 Replies Latest reply on May 9, 2008 10:41 AM by Joe ... Ward

    How to retrieve data in air application

      Hi All,

      I have problem with fetching the data from database. I don't know how to collect data. Like in .NET we have DataTable/Dataset for collecting data. How to collect data into adobe air.? I can INSERT,UPDATE and DELETE the data dynamically. But stuck with the SELECT statement. As my application is mortgage based, there are lots of data to be displayed on the adobe screen. Can anyone please assist me for this?
      Thank you
        • 1. Re: How to retrieve data in air application
          Hi Vinshell,
          I didn't well understand your question but if you want to retreive data without writing any sql , i doubt you can't.
          but i think you can use dataGrid and data binding with little SQL and things will get done.
          yours desinta.
          • 2. How to retrieve data in air application
            Joe ... Ward Level 4
            The SQL statement results in a SQLResult object that you can get from the SQLConnection object using getResult().

            For example, if I create and execute the following SQLStatement against a SQLConnection object referenced by connection:
            var getAllQuery:SQLStatement = new SQLStatement();
            getAllQuery.text = "SELECT * FROM foo;";
            getAllQuery.addEventListener(SQLEvent.RESULT, setData);
            getAllQuery.sqlConnection = connection;

            Then, the setData() event handler is called in response to the completion of the query:

            private function setData(event:SQLEvent):void{
            tableView.dataProvider = event.target.getResult().data;

            In this example, event.target is the SQLConnection object for the database. The handler calls the getResult() function to get the most recent result. The function sets the dataProvider property of the following DataGrid component to the result data property. This results in the SQL results being displayed in the DataGrid.

            The definition of the DataGrid is (although only the id is really significant to this example):
            <mx:DataGrid id="tableView" top="0" bottom="0" right="0" width="100%" height="100%">

            If you have a lot of queries that may be returned in non-determinate order, then you can use a Responder object to deal with each query as it is produced, rather than just getting the most recent result with getResult().

            Edit: I just noticed that you are using HTML. The basics are still the same, but of course, you can't use the DataGrid. You will have to consume the SQLResult object and insert the appropriate data into your HTML objects. See http://livedocs.adobe.com/air/1/jslr/flash/data/SQLResult.html