MySQL Database Usage

  1. 5 years ago

    TheMexican

    21 Jun 2018 User since 2016

    I have created a MySQL database under Globals. I have several questions as to the proper use of Objects created at design time.
    MySQL Databases created during Design

    1. Are they initialized as soon as the app runs?
    2. Are they always connected?
    3. How about child queries under the database? Are they initialized and data obtained as soon as App runs?

    I have a Window with 2 labels (lblFirst and lblLast), I want the labels to show the value of a Mysql query. I am having a hard time doing this. Maybe I am thinking in "traditional" programming terms.

    Any ideas?

    Thanks!!

  2. andrea

    21 Jun 2018 Administrator User since 2016

    Hi @TheMexican,
    1. Global objects a initialized as soon as the app runs
    2. Databases connect automatically when a child recordset (query) runs. A query runs automatically when attached as a dataset of a control (this happens only when the Window that contains the control is about to appear for the first time).
    3. Child queries are initialized as soon as App runs, but don't run until used by some controls (see the previous point) or the run method is invoked by your code.

    If you have a Window with 2 labels, you can invoke programmatically the execution of the query with MySQL1.Query1.run(), for example in the WillShow event of your Window.
    You can show the result of the query in the 2 labels, for example, by adding the following code in the DidFinish event of the Query1:

    Window1.lblFirst.text = Query1.stringValue(0); // get the string value of the first column of the current row
    Window1.lblLast.text = Query1.stringValue(1); // get the string value of the second column of the current row
  3. TheMexican

    22 Jun 2018 User since 2016

    Thank you very much this helps me a lot.
    I can see that I have to program in an event based paradigm.

    Will try.

or Sign Up to reply!