Hello.
Imagine MySQL database with one table which contains these columns: "UserId, UserName".
Now, we want to fill Combobox with all users in database ordered by their names.
Combobox.Clear;
Query.SQL.Text := 'SELECT * FROM users';
Query.Open;
while not Query.EOF then begin
Combobox.Items.Add(Query.FieldByName('UserName').AsString);
Query.Next;
end;
Query.Close;
All users are showed in items of Combobox. And the problem is... how can I recognize ID of the selected user? I can't do it by his name because of duplicate rows. Is there any way to do this easy? Thanks for helping.