Zitat:
while not fResult.Eof do begin
i := i+1;
MainFrm.LView.Items.Add;
MainFrm.LView.Items[i].Caption := fResult.FieldValueByName('id');
MainFrm.LView.Items[i].SubItems.Add(fResult.FieldValueByName('name'));
MainFrm.LView.Items[i].SubItems.Add(fResult.FieldValueByName('mail'));
fResult.Next;
end;
versuch mal hier hinter noch ein 'freeandnil(fresult)'
Zitat:
q := 'SELECT * FROM test';
greifst du damit auf die
MySQL eigene Datenbank 'test' zu ?
edit: Code umgestellt ...
Delphi-Quellcode:
procedure Auflisten;
var ex: boolean;
q: string;
i, records: Integer;
begin
if fMySql.Connect then
begin
if assigned(FResult) then
begin
if FMysql.Status<>MYSQL_STATUS_READY then
FreeAndNil(FResult);
end;
q := 'SELECT * FROM test';
fResult := fMySql.query(q,true,ex);
records := fResult.RowsCount;
MainFrm.lview.Clear;
for i:=0 to records-1 do
begin
MainFrm.LView.Items.Add;
MainFrm.LView.Items[i].Caption := fResult.FieldValueByName('id');
MainFrm.LView.Items[i].SubItems.Add(fResult.FieldValueByName('name'));
MainFrm.LView.Items[i].SubItems.Add(fResult.FieldValueByName('mail'));
fResult.Next;
end;
FreeAndNil(fResult);
end;
end;
cya