Board index » delphi » Query DB into a ListView - FREEZE

Query DB into a ListView - FREEZE


2005-06-06 03:43:22 AM
delphi139
I've got a TADOQuery from which I want to add values to a ListView, here's
what I am doing:
var
l: TListItem;
quey1.SQL.text=...
query1.open;
while not Query1.Eof do
begin
l := lista.Items.Add;
l.Caption := Query1.FieldByName('Naziv robe').AsString;
l.SubItems.Add(Query1.FieldByName('Jed mere').AsString);
l.SubItems.Add(Query1.FieldByName('Kval').AsString);
l.SubItems.Add(Query1.FieldByName('Kolicina').AsString);
l.SubItems.Add(Query1.FieldByName('Cena po kg').AsString);
l.SubItems.Add(Query1.FieldByName('Vrednost bez PDV').AsString);
l.SubItems.Add(Query1.FieldByName('PDV procenat').AsString);
l.SubItems.Add(Query1.FieldByName('Iznos PDV').AsString);
l.SubItems.Add(Query1.FieldByName('Vrednost sa PDV').AsString);
end;
query1.close;
Just when I pree the query button th app stops, it seems it is doing
something, but there are only 10 fields that match the query conditions.
What am I doing wrong? I also tried it like this:
for i := 0 to Query1.RecordCount - 1 do
but though it is fast I get 10 identical ListView items, is there a way to do
this right, maybe something like
Query1.Records[i].FieldByName('...').AsString ?
Marko
 
 

Re:Query DB into a ListView - FREEZE

You are in an endless loop. The last line of the While not Query1.EOF
loop must be
Query1.Next;
You are looping forever on the first record.
--
Bill Todd (TeamB)
 

Re:Query DB into a ListView - FREEZE

Quote
You are in an endless loop. The last line of the While not Query1.EOF
loop must be

Query1.Next;

You are looping forever on the first record.
Thanks Bill, I am sorry for this stupid question, but I have never worked with
databases before, if you're interested in seeing my work take a look at
mxs.bergsoft.net
Regards
Marko
 

Re:Query DB into a ListView - FREEZE

There is nothing stupid about your question. That is a very easy
mistake to make.
--
Bill Todd (TeamB)