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 7818005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:25:38+00:00 2026-06-02T06:25:38+00:00

About me: I am just starting out. I know there has to be a

  • 0

About me:
I am just starting out. I know there has to be a simple way to do this, but after a week I am still stumped.
What it is:
I have made an app to replace a very long written procedure. I would like to have text input boxes populated with the previous given answer for the test they are running.
Problem:
I can get the correct info from the DB; however I cannot put it in the text input field.
The box just displays: [object Object]

Any help would be greatly appreciated.

Here is sample code for the Settings.mxml page:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="Settings" >
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:Label id="DB_Name_Label" left="10" top="10" width="150" height="50" fontSize="28"
             text="DB Name" textAlign="right" verticalAlign="middle"/>
    <s:TextInput id="DB_Name_Input" left="170" top="10" width="300" height="50" fontSize="32"/>

    <s:Label id="Test_Title" left="10" top="70" width="150" height="50" fontSize="28"
             text="Test Title" textAlign="right" verticalAlign="middle"/>
    <s:TextInput id="Test_Title_Input" left="170" top="70" width="300" height="50" fontSize="32"/>

    <s:Button id="Equipment_Button" left="10" right="10" top="130" height="50"
              label="Save, then next Page" click="EquipmentButtonClick()"/>

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import spark.events.ViewNavigatorEvent;     

            protected var sqlConnection:SQLConnection;

            public function add_info_to_DB(tableName:String, valueToBeSaved:String):void
            {
                sqlConnection = new SQLConnection();
                sqlConnection.open(File.userDirectory.resolvePath(DB_Name_Input.text+".db"));
                var add2db:SQLStatement = new SQLStatement();
                add2db.sqlConnection = sqlConnection;
                add2db.text = ("CREATE TABLE IF NOT EXISTS "+tableName+" (id INTEGER PRIMARY KEY AUTOINCREMENT, answer TEXT)");
                add2db.execute();

                add2db.text = "INSERT INTO "+tableName+" (answer) VALUES (?)";
                add2db.parameters[0] = valueToBeSaved;
                add2db.execute();
            }

            [bindable] public var testdata:Object= new Object();

            protected function EquipmentButtonClick():void
            {   
                add_info_to_DB("Test_Title",Test_Title_Input.text);         
                navigator.pushView(views.ReadfromDB, testdata);
            }
        ]]>
    </fx:Script>
</s:View>

Here is code for the ReadfromDB.mxml page:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="Reading" >
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:Label id="DB_to_Read_Label" left="10" top="10" width="150" height="50" fontSize="28"
             text="DB to Read" textAlign="right" verticalAlign="middle"/>
    <s:TextInput id="DB_to_Read" left="170" top="10" width="300" height="50" fontSize="32"/>

    <s:Label id="Test_Title" left="10" top="70" width="150" height="50" fontSize="28"
             text="Test Title" textAlign="right" verticalAlign="middle"/>
    <s:TextInput id="Test_Title_Input" left="170" top="70" width="300" height="50" fontSize="32"/>

    <s:Button id="Populate_Button" left="10" right="10" top="130" height="50" label="Populate"
              click="PopulateButtonClick()"/>

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import spark.events.ViewNavigatorEvent;     

            protected var sqlConnection:SQLConnection;
            public var valueToBeRead:String;

            public function get_DB_info(tableName:String):void
            {   
                sqlConnection = new SQLConnection();
                sqlConnection.open(File.userDirectory.resolvePath(DB_to_Read.text+".db"));
                var add2db:SQLStatement = new SQLStatement();
                add2db.sqlConnection = sqlConnection;
                add2db.text = ("SELECT answer FROM "+tableName+" ORDER BY id DESC LIMIT 1");
                add2db.execute();
                valueToBeRead = add2db.getResult().data.toString();//.valueOf();//.toString();
            }

            protected function PopulateButtonClick():void
            {   
                get_DB_info("Test_Title");  
                Test_Title_Input.text = valueToBeRead;
            }
        ]]>
    </fx:Script>
</s:View>
  • 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-02T06:25:41+00:00Added an answer on June 2, 2026 at 6:25 am

    When you call add2db.getResult() the return object is a SQLResult. The info there about the data property is very useful. It says that the data property is an Array of Objects containing your result.

    In your case, it looks like your SQL query will return exactly 1 database row, and that row contains only one column: answer

    So you should therefore be able to populate the text input like this:

    var firstRow:Object = add2db.getResult().data[0];
    valueToBeRead = firstRow["answer"];
    // or, instead of storing it in a variable, just assign it to the text input right away
    Test_Title_Input.text = firstRow["answer"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there's an easy way of doing this, but my recursion abilities are
I'm just starting out with Paypal, so this is a newbie question. I've been
I don't know if this is the place to ask about algorithms. But let's
I'm about to start building a new asp.net project, and I'm just starting out
I just starting reading about SEO and realized that I should change my GET
I'm just starting to learn about printing with Java Swing, so please bear with
I am just starting to learn a little about PHP; having trouble with the
I'm just about getting into WCF ; but from what I've read so far,
I am just starting out with writing jQuery plugins. I wrote three small plugins
I'm looking at implementing an RDBMS. Are there any good resources out there about

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.