Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8698877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:49:09+00:00 2026-06-13T01:49:09+00:00

I’m making a mobile app in flex 4.5, I want to get name of

  • 0

I’m making a mobile app in flex 4.5, I want to get name of person and age of person then save to sqlite database done my code looks like :

public var personNamesDB:File;
        public var dbConnection:SQLConnection;

        protected function createDatabase(event:FlexEvent):void
        {
            // TODO Auto-generated method stub
            personNamesDB = File.applicationStorageDirectory.resolvePath("person.db");
            dbConnection = new SQLConnection();
            dbConnection.openAsync(personNamesDB, SQLMode.CREATE);
            dbConnection.addEventListener(SQLEvent.OPEN, onDatabaseOpened);
            dbConnection.addEventListener(SQLEvent.CLOSE, onDatabaseClosed);



        }// end createDatabase method

protected function onDatabaseOpened(arshayEvent:SQLEvent):void
        {
            trace("DB Opened");
            var statement:SQLStatement = new SQLStatement();
            statement.sqlConnection = dbConnection;
            statement.text = "CREATE TABLE IF NOT EXISTS personinfo(id INTEGER PRIMARY KEY AUTOINCREMENT, nameofperson TEXT, ageofperson TEXT)";

            statement.execute();
            // for showing saved city names in list on App start up
            showSavedNames();
            trace("table created");
        }

Now for Inserting data code is :

///////////////////////////////////
        public var insertData:SQLStatement
        protected function saveName():void
        {
            // SQLite Usage
            insertData = new SQLStatement();
            insertData.sqlConnection = dbConnection;
            insertData.text = "INSERT INTO personinfo(nameofcity, ageofperson) VALUES(:nameofcity, :ageofperson)";
            insertData.parameters[":nameofcity"] =nameInput.text;
            insertData.parameters[":ageofperson"] = ageInput.text;
            insertData.addEventListener(SQLEvent.RESULT, dataInsertedSuccess);
            trace("Name " + nameInput.text);
            insertData.execute();

            showSavedNames();

        }

        protected function dataInsertedSuccess(event:SQLEvent):void
        {
            trace(insertData.getResult().data);
        }
        //////////////////////////////////////////////
        public var selectQuery:SQLStatement;
        protected function showSavedNames():void
        {
            selectQuery = new SQLStatement();
            selectQuery.sqlConnection = dbConnection;
            selectQuery.text = "SELECT * FROM personinfo ORDER BY nameofperson ASC";
            selectQuery.addEventListener(SQLEvent.RESULT, showNamesInList);

            selectQuery.execute();
        }

        protected function showNamesInList(event:SQLEvent):void
        {
            listOfAddedNames.dataProvider = new ArrayCollection(selectQuery.getResult().data);
        }

mxml code for list control is :

<s:List id="listOfAddedNames" width="345" height="100%" labelField="nameofperson"
            click="get_names_data(event)"/>

Now get_names_data method is like :

public var selectNameQuery:SQLStatement;

        protected function get_names_data(event:MouseEvent):void
        {
            // TODO Auto-generated method stub

            var currentName:String = listOfAddedNames.selectedItem.nameofperson;

            selectNameQuery = new SQLStatement();
            selectNameQuery.sqlConnection =dbConnection;
            selectNameQuery.text = "SELECT ageofperson FROM personinfo WHERE (nameofperson = '" + currentName + "')";
            selectNameQuery.addEventListener(SQLEvent.RESULT, nowGotAge);

            selectNameQuery.execute();
            trace("current selected   >> "+currentName);
        }

        protected function nowGotAge(event:SQLEvent):void
        {

            trace("Age of selected Name is >> "+selectNameQuery.getResult().data.ageofperson);
        }

On this line :

trace("Age of selected Name is >> "+selectNameQuery.getResult().data.ageofperson);

No data is fetched from database and trce is displaying “undefined” please solve this for me and tell me how to get data from ageofperson column according to selected name in list of person names– Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:49:10+00:00Added an answer on June 13, 2026 at 1:49 am

    First problem with need to understand async execution model because you opened sqlite database async mode.
    Second problem with column name ‘nameofcity’ that person table doesn’t have any column like you declared.so i modify here as ‘nameofperson’ in saveName().

    Where you call saveName() please make sure that you have called ‘saveName()’.

    In dataInsertedSuccess() In sqlquery return no of affected row only when run againt INSERT/UPDATE sql query ie, only return integer value. So always insertData.getResult().data is null/undefined.it will contain(s) data if you run SELECT sql query.

                public var personNamesDB:File;
            public var dbConnection:SQLConnection;
    
            protected function createDatabase(event:FlexEvent):void
            {
                // TODO Auto-generated method stub
                personNamesDB = File.applicationStorageDirectory.resolvePath("person.db");
                dbConnection = new SQLConnection();
                dbConnection.openAsync(personNamesDB, SQLMode.CREATE);
                dbConnection.addEventListener(SQLEvent.OPEN, onDatabaseOpened);
                dbConnection.addEventListener(SQLEvent.CLOSE, onDatabaseClosed);
            }// end createDatabase method
    
            protected function onDatabaseOpened(arshayEvent:SQLEvent):void
            {
                trace("DB Opened");
                var statement:SQLStatement = new SQLStatement();
                statement.sqlConnection = dbConnection;
                statement.text = "CREATE TABLE IF NOT EXISTS personinfo(id INTEGER PRIMARY KEY AUTOINCREMENT, nameofperson TEXT, ageofperson TEXT)";
                statement.addEventListener(SQLEvent.RESULT ,function(event:SQLEvent):void
                {
                    trace("table created");
                    // for showing saved city names in list on App start up
                    showSavedNames(); **//Need to call after get success event**
                });
                statement.execute();
            }
    
            public var insertData:SQLStatement
            protected function saveName():void
            {
                // SQLite Usage
                insertData = new SQLStatement();
                insertData.sqlConnection = dbConnection;
                insertData.text = "INSERT INTO personinfo(nameofperson, ageofperson) VALUES(:nameofperson, :ageofperson)";
                insertData.parameters[":nameofperson"] = "Xyz";
                insertData.parameters[":ageofperson"] = "27"
                insertData.addEventListener(SQLEvent.RESULT, dataInsertedSuccess);
                insertData.addEventListener(SQLErrorEvent.ERROR, function(event:SQLErrorEvent):void
                {
                    //details   "table 'personinfo' has no column named 'nameofcity'"   
                    trace(event.error.message.toString());
                    //                  showSavedNames();
                });
                insertData.execute();
            }
    
            protected function dataInsertedSuccess(event:SQLEvent):void
            {
                trace("Success :: " + insertData.getResult().rowsAffected);
                showSavedNames();
            }
            //////////////////////////////////////////////
            public var selectQuery:SQLStatement;
            protected function showSavedNames():void
            {
                selectQuery = new SQLStatement();
                selectQuery.sqlConnection = dbConnection;
                selectQuery.text = "SELECT * FROM personinfo ORDER BY nameofperson ASC";
                selectQuery.addEventListener(SQLEvent.RESULT, showNamesInList);
                selectQuery.execute();
            }
    
            protected function showNamesInList(event:SQLEvent):void
            {
                listOfAddedNames.dataProvider = new ArrayCollection(selectQuery.getResult().data);
            }
    
            public var selectNameQuery:SQLStatement;
    protected function get_names_data(event:MouseEvent):void
            {
                //Need not to get ageofperson from db
                Alert.show(listOfAddedNames.selectedItem.ageofperson);
    
                //Any way continue your way
                var currentName:String = listOfAddedNames.selectedItem.nameofperson;
    
                selectNameQuery = new SQLStatement();
                selectNameQuery.sqlConnection =dbConnection;
                selectNameQuery.text = "SELECT ageofperson FROM personinfo WHERE nameofperson = '" + currentName + "'";
                selectNameQuery.addEventListener(SQLEvent.RESULT, nowGotAge);
                selectNameQuery.execute();
                trace("current selected   >> "+currentName);
            }
    
            protected function nowGotAge(event:SQLEvent):void
            {
                trace("Age of selected Name is >> "+selectNameQuery.getResult().data[0].ageofperson);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.