AW: Datenbank- Quiz programmieren
9. Mär 2020, 22:19
ich habs mal so versucht, im prinzip habe ich nicht viel verändert
procedure TFormle.ButtonnextClick(Sender: TObject);
function ist_leer: boolean;
begin
result := datamodule1.ADOQuery6.IsEmpty;
end;
function open_query: boolean;
begin
try
if datamodule1.ADOQuery6.Active = true then
result := true
else
begin
datamodule1.ADOQuery6.SQL.Clear;
datamodule1.ADOQuery6.SQL.Text :='SELECT Frage, L1, L2, L3 FROM Fragen WHERE Fach = ' + #39 + Lb.Items.Strings[Lb.ItemIndex] + #39 + ' AND Schwierigkeit="1";';
datamodule1.ADOQuery6.Active := true;
datamodule1.ADOQuery6.First;
first_open := true;//TFormle private deklariert
result := true;
end;
except
result := false;
end;
end;
procedure set_caption;
begin
rg.caption := '';
rg.caption := datamodule1.ADOQuery6.Fields[0].AsString;
// Antworten in Radiobuttons
rg.Items.Clear;
rg.Items.Add(datamodule1.ADOQuery6.Fields[1].AsString);
rg.Items.Add(datamodule1.ADOQuery6.Fields[2].AsString);
rg.Items.Add(datamodule1.ADOQuery6.Fields[3].AsString);
end;
begin
if Lb.ItemIndex >= 0 then
begin
if open_query = false then exit
else
if ist_leer = true then begin
showmessage('Keine Daten');
exit
end
else
begin
rg.Visible := true;
if first_open = true then
begin
set_caption;
first_open := false;
end
else
begin
datamodule1.ADOQuery6.Next;
set_caption;
end;
end;
end
else
application.MessageBox('Auswahlfehler!', 'Fehler');
end;
keine Garantie
Gruß
|