Solved

ADOQuery + ComboBox

Posted on 2003-10-24
3
704 Views
Last Modified: 2010-04-16
I have a ADOQuery and a ComboBox
i give a sql command
select * from stock where price>1000
all the selected fields i want to add in ComboBox
How can i do this ?
Thanks
0
Comment
Question by:fradolcino
3 Comments
 
LVL 1

Expert Comment

by:Qosai_DBA
ID: 9618928
Hi fradolcino

if I know you can concatenate all fields first like

SELECT field1 || field2 || field3 || ... || ... AS allfields FROM stock WHERE price>1000;

so the result of this Query is only one field and you can add the values to the ComboBox.

Regards
khalid.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 45 total points
ID: 9618938
var
  i : integer;
  s : String;
begin
  adoquery1.open;
  while not adoquery1.eof do
  begin
    s := '';
    for i := 0 to adoquery1.fields.count-1 do
      s := s + adoquery1.Fields[i].AsString;
    combobox1.Items.add(s);
    adoquery1.next;
  end;
  adoquery1.Close;
end;

meikl ;-)
0
 
LVL 4

Expert Comment

by:brunomsilva
ID: 9620059
Hi,

why don't you use associate a datasource control with your query and then use it as a datasource for a dbLookupComboBox. Then you just have to set the KeyField propery to the field you want.

bye,
 Bruno
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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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