Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- //Use a second TQuery, to perform changes, and avoid exception after ExecSQL
- with ASQLite3Query2 do begin
- Close;
- SQL.Clear;
- SQL.Text := 'INSERT INTO books (isbn,language) VALUES (NULL,:a)';
- Params[0].AsString := 'test';
- ExecSQL;
- end;
- ASQLite3Query1.Refresh;
- end;
- procedure TForm1.FormActivate(Sender: TObject);
- begin
- With ASQLite3DB1 do begin
- DefaultDir := ExtractFileDir(Application.ExeName);
- Database := 'mybooks.sqlite';
- Open;
- SQLite3_ExecSQL('CREATE TABLE IF NOT EXISTS books (isbn INTEGER PRIMARY KEY, language VARCHAR)');
- end;
- //Do I need TUpdateSQL?
- With ASQLite3UpdateSQL1 do begin
- InsertSQL.Text := 'INSERT INTO books *';
- end;
- With ASQLite3Query1 do begin
- Connection := ASQLite3DB1;
- SQL.Text := 'SELECT * FROM books';
- UpdateSQL := ASQLite3UpdateSQL1;
- Open;
- end;
- //Do I need a second TQuery?
- With ASQLite3Query2 do begin
- Connection := ASQLite3DB1;
- SQL.Text := 'SELECT * FROM books';
- UpdateSQL := ASQLite3UpdateSQL1;
- Open;
- end;
- DataSource1.DataSet := ASQLite3Query1;
- With NextDBGrid1 do begin
- DataSource := DataSource1;
- Columns[ASQLite3Query1.FieldCount-1].Options := NextDBGrid1.Columns[ASQLite3Query1.FieldCount-1].Options + [coAutoSize];
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement