Programuje właśnie komunikator. Mam w timerze sprawdzanie nowych wiadomości(thread):
procedure recmess.Execute;
begin
for i := 0 to (Form3.contacts.Items.Count - 1) do
if Form3.contacts.Selected[i] = true then
Form3.messages.ParamByName('t').AsString := Form3.contacts.items[i];
Form3.messages.ParamByName('l').AsString := Form1.polelogin.Text;
Form3.messages.Open;
while not Form3.messages.eof do
begin
if (Form3.messages.FieldByName('from').asstring) = (Form1.polelogin.text) then
Form3.talk.Lines.Add(Form1.polelogin.Text + ': ' + Form3.messages.FieldByName('message').asstring);
if ((Form3.messages.FieldByName('from').asstring) = (Form3.contacts.Items[i])) then
Form3.talk.Lines.Add(Form3.contacts.Items[i] + ': ' + Form3.messages.FieldByName('message').asstring);
Form3.messages.Next;
end;
Form3.messages.Close;
end;
Niestety ta procedura pokazuje tylko pierwsza wiadomość z tabelki.
Kod SQL jest taki:
SELECT *
FROM `messages`
WHERE (`from` = :l OR `from` = :t) AND (`to` = :l OR `to` = :t) AND `read` = 1
Proszę o pomoc