Solved

Basic question...

Posted on 2000-02-16
6
195 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now