Recent

Author Topic: TSqlite3Dataset with two tables [SOLVED]  (Read 2934 times)

vice

  • New Member
  • *
  • Posts: 28
TSqlite3Dataset with two tables [SOLVED]
« on: October 14, 2008, 02:19:01 am »
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?

Code: [Select]

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:

Code: [Select]
SQL := '';

before the Open;

 

TinyPortal © 2005-2018