Execute procedure in Delphi loop

Hi I have another question for Experts
I have an ordinary loop in Delphi code and I want to execute some simple procedure:
str : string;
chquery.Active := false;
chquery.SQL.Text:='SELECT * from table1';
while not chquery.Eof do
    str := chquery.FieldByName('title').AsString;
   Label1.Caption  := str;

I wann for each record Label1 to show me field Title, but in my case it show only the last one when the loop is end
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

F IgorDeveloperCommented:
When you are in a loop the window cannot be updated unless you add a line after setting the caption:


Open in new window

Allowing your program to "repaint" the window each loop.
Tryn adding this line after

Label1.Caption  := str;

Open in new window

And you can reduce the sleep time (there is no need of sleep to make it work)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sinisa VukSoftware architectCommented:
This - should be fine in your case - without: Application.ProcessMessages.
Label1.Caption  := str;

Open in new window

...and if you open query - then you don't need to execute:
chquery.SQL.Text:='SELECT * from table1';

Open in new window

Sql update,insert or delete - should call ExecSQL.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.