I have two buttons, when I push Button1 the FIELD1´s data of TABLE1 are shown in Memo1 but if I push Button2 to change table and repeat the previous operation I get an error, why?
procedure TForm1.Button1Click(Sender: TObject);
begin
with Sqlite3Dataset1 do
begin
TableName := 'TABLE1';
Open;
First;
while not Eof do
begin
Memo1.Lines.Add(FieldByName('FIELD1').AsString);
Next;
end;
Close;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with Sqlite3Dataset1 do
begin
TableName := 'sqlite_master';
Open;
First;
while not Eof do
begin
if FieldByName('type').AsString = 'table' then
Memo1.Lines.Add(FieldByName('tbl_name').AsString);
Next;
end;
Close;
end;
end;
Regards.
EDIT: One solution is to use a Dataset for each table, another solution is:
SQL := '';
before the Open;