Solved

ADOQuery + ComboBox

Posted on 2003-10-24
3
702 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

13 Experts available now in Live!

Get 1:1 Help Now