Solved

Basic question...

Posted on 2000-02-16
6
198 Views
Last Modified: 2010-04-04
I have a simple query like this

Select * from <Table>

when I put a DataSource and a DBCombo, the DBCombo not show the data. The Combo only show the first record of dataset.

Any idea?

Thanks, Marcelo
0
Comment
Question by:Marcelito
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:aubs
ID: 2526828
The idea of the DBCombobox is that you fill the items list yourself to allow the user to select an appropriate one for the field.

If you are expecting to see all the records of a particular field in a combo box use the DBLookupComboBox

Aubs
0
 

Expert Comment

by:hobbit123
ID: 2526829
I don't understand. You want do use a TDBComboBox component with TDataSource? You need to set DataSource and DataField properties and everything should be fine. If you want to see a next record, you should call <YourDataSetName>.Next;
 
                   Hobbit123

0
 
LVL 1

Expert Comment

by:JoeBooth
ID: 2526896
Use a DBLOOKUPCOMBO instead of a DBCOMBO and set the ListSource and ListField properties to the datasource and field name.

DBCOMBO expects you to fill the list box and controls what gets entered into the field.

DBLOOKUPCOMBO fills the list box with items from the dataset specified in the Listsource
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:ITugay
ID: 2526900
Of course, you will see nothing, if you place nothing in TDBComboBox.Items.
You can fill it at design time by enter desired values manually, or in runtime.
In runtime you may do it like this:

in designmode define OnDropDown event.

procedure TForm1.DBCombobox1.DropDown(Sender: TObject);
begin
   DBCombobox1.Items.Clear;
   DBCombobox1.Items.Add('000');
   DBCombobox1.Items.Add('001');
   DBCombobox1.Items.Add('02');
   DBCombobox1.Items.Add('text');
// you may fill list by values from anoter table
end;

Cheers,

Igor.
0
 

Expert Comment

by:GoodTimes
ID: 2531913
DBComboBox is intended to allow the user to pick a value for a specific field. It is not intended to select a record in the database.
If you want to fill the DBComboBox with data from the table do the following:

with Table do
begin
   First;
   while not EOF do
   begin
      DBCombo.Items.Add(FieldByName('ComboField').AsString);
      Next;
   end;
end;

This should add the values in the table to the dbcombobox.
put in FieldByName the name of the field which the dbcombobox is supposed to represent.

I hope this explains things a bit..
Omri
0
 

Accepted Solution

by:
Freaky earned 50 total points
ID: 2551984

The only data-sensitive thing in a DBComboBox is the editfield.
The dropdown-list does not contain the records from your query.

Try to insert the datarows like "GoodTimes" explained above, but set a "DBComboBox.Items.Clear" just behind the "Table.First" or your list will be quite full after some expandings .. ;)

 Greets

  Sascha

PS: Sorry for my bad English - German is easier, I think .. ;)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question