1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
procedure TForm2.FormCreate(Sender: TObject);
var
col, row : Integer;
begin
with ASQLite3DB1 do begin
DefaultDir := ExtractFileDir(Application.ExeName);
Database := 'db.sqlite';
Open;
SQLite3_ExecSQL('CREATE TABLE IF NOT EXISTS products (id integer primary key, name TEXT)');
SQLite3_ExecSQL('INSERT INTO products (id, name) VALUES (NULL,"test")');
end;
DataSource1.DataSet := ASQLite3Query1;
SMDBGrid1.DataSource := DataSource1;
//No trace of an .Open or .Activate method
With ASQLite3Query1 do begin
Connection := ASQLite3DB1;
SQL.Text := Format('SELECT %s FROM products',['products.*']);
Open;
//Grid says "No data to display"
//SMDBGrid1.Enabled := True;
//SMDBGrid1.Update;
//SMDBGrid1.Show;
//SMDBGrid1.Refresh;
First;
while not Eof do begin
for col := 0 to Fields.Count - 1 do begin
ListBox1.Items.Add(Fields[col].AsString);
end;
Next;
end;
Close;
end;
ASQLite3DB1.Close;
end; |
Partager