So, I was busy with a new project in Delphi 2009, and the default components that can be dropped onto the data access form consist of SQLConnection, DataSource and SQLQuery. If I add a simple query element to the query component, say:
select name from customers
and then drop the DBComboBox on the form and associate it with the DataSource. I get one entry in the combo box. After using Google for half an hour to figure out what I'm doing wrong, it looks like you need to manually add code to your project, which iterates over the data set and adds all the entries to the drop-down list. Sort of:
while not SQLQuery.eof do
begin
DBComboBox.items.add(SQLQuery.fieldbyname('name').asstring);
SQLQuery.next;
end;
And it really works, but then you get a list in the drop-down list from which you canβt choose anything. Regardless of the result, although I wonder why you even use DBComboBox if you need to manually add the result of your query to it? It seems to me that if it does not automatically fill in the db combo box with the query result, we could also use a component that does not support data, for example tcombobox.
I suppose I ask why it works this way? Isn't the goal of data management with drag and drop control to minimize the amount of actual code and development speed? Is there a way that I'm missing that should make this easier?