Search code examples
sqlitedelphifiremonkeydelphi-xe5firedac

Show sqlite query results in a TEdit - Firemonkey Mobile application?


I have an sqlite database and i want to execute a select query and show the result in the TEdit. How can i do it?

 query := 'SELECT username FROM users';  //The query returns only one row
 FDQuery1.ExecSQL;
 FDQuery1.Open();
 Edit1.Text := ??

Solution

  • In your case, because you only have 1 column I would use:

    Edit1.Text := FDQuery1.Fields[0].AsString;
    

    But if you have mulitple column you select I would use:

    Edit1.Text := FDQuery1.fieldbyname(<ColumnName>).AsString;