A
A
Alexander Vishnev2021-11-26 17:05:24
Delphi
Alexander Vishnev, 2021-11-26 17:05:24

How to properly load data into ListView?

Loading data from sqlite into listview.
But as a result, FDQuery1 is loaded correctly, in turn, but FDQuery2 is loaded for the same questions.
This is understandable.
for i:=0 to FDQuery1.Record Count-1 do
I tried like this:
for i:=0 to FDQuery1.RecordCount -1 and FDQuery2.RecordCount -1 do
doesn't help...

ListView1.Items.Clear;
    FDQuery1.Close;
    FDQuery2.Close;
    FDQuery1.Active:=True;
    FDQuery2.Active:=True;
    FDQuery1.SQL.Clear;
    FDQuery2.SQL.Clear;
    FDQuery1.SQL.Add('select question from datai');
    FDQuery2.SQL.Add('select answer from datai');
    FDQuery1.OpenOrExecute;
    FDQuery2.OpenOrExecute;
ListView1.BeginUpdate;
for i:=0 to FDQuery1.RecordCount -1 and FDQuery2.RecordCount -1 do
     begin
     mr :=(FDQuery1.FieldByName('question').AsString);
     mr2 :=(FDQuery2.FieldByName('answer').AsString);
       ListView1.Items.Add.Data['result] := mr+chr(13)+chr(13)+mr2;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kalapanga, 2021-11-26
@fromdns

1) The code is not fully inserted.
2) It shouldn't compile at all, let alone help. Some nonsense for i:=0 to FDQuery1.RecordCount
-1 and FDQuery2.RecordCount -1 do
3) Why are two FDQuery objects needed here? Do in one
'select question, answer from datai'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question