3 Replies Latest reply on Dec 28, 2010 11:59 AM by Laxidasical

    How Do I... Read A Single SQL Record... Without A Data Grid...

    Bill Brutzman

      Flash Builder 4 is connected ok to ColdFusion and MySQL via the FB auto-generated CFCs.

       

      I am trying to put the users table key in an TextInput field and click a [Get] button to get the record.

       

      protected function get_clickhandler(event.MouseEvent):void

           {

           getusersResult.token = usersService.getusers(users.USERID)

           }

       

      The network monitor indicates that the getusers method is working.

       

      So... I do not know what to do with this token thing.  How do get the record data so that FlashBuilder can display it.

       

      Help would be appreciated.  Reference info would be appreciated.

       

      Regards,

       

      --Bill

        • 1. Re: How Do I... Read A Single SQL Record... Without A Data Grid...
          Laxidasical

          I just figured this out last week.  Here is an example, assume a "contacts" table exists with a "first_name", a "last_name", and an "email" field...

           

          1) Make a connection to your SQLite DB if you haven't already:

           

          sqlConnection = new SQLConnection();
          sqlConnection.open(File.applicationStorageDirectory.resolvePath("yourdbfile.db"));
          var sql:SQLStatement = new SQLStatement();
          sql.sqlConnection = sqlConnection;
          getAccountInfo();
          

           

          2) get the data and put it in an array:

           

          var sql:SQLStatement = new SQLStatement();
          sql.sqlConnection = sqlConnection;
          sql.text = "SELECT first_name, last_name, email FROM contacts WHERE id = 1 LIMIT 1;";
          sql.execute();
          var contactInfo:Array = sql.getResult().data;
          

           

          3) Access the data directly or assign to variables:

           

          var firstName:String = contactInfo[0].first_name;
          var lastName:String  = contactInfo[0].last_name;
          var email:String     = contactInfo[0].email;
          

           

          Hope this helps...

          • 2. Re: How Do I... Read A Single SQL Record... Without A Data Grid...
            Bill Brutzman Level 1

            Lax...

             

            Thanks for writing...I was able to get the answer from your response...

             

            from the... getuserResult.token = ... I can gather the last name in the database via

             

                 users.LAST = getusersResult.lastResult[0].LAST

             

            In a way, I misstated the question from the perspective that ColdFusion is doing all of the SQL.

             

            Regards,

             

            --Bill

            • 3. Re: How Do I... Read A Single SQL Record... Without A Data Grid...
              Laxidasical Level 1

              That was my mistake actually, I was skimming instead of reading!  Glad I could help still...