Recent

Author Topic: [SOLVED]SQLite3Connection Connected, But Does Not Display Values Within The Grid  (Read 1268 times)

sunbreezy393

  • New Member
  • *
  • Posts: 11
Hi there, I am new to programming with databases and I have created a test database using SQLite. I created an if statement which calls to a label to identify whether the database is connected. It says its connected but does not display the values within DBGrid. If anyone can help I would be most grateful.

Here is the code I have written below........

procedure TfrmSqliteTest.ConnectButtonClick(Sender: TObject);
begin
  SQLite3Connection1.DatabaseName := 'sqltest.db';
  SQLite3Connection1.Transaction := SQLTransaction1;

  SQLTransaction1.Database := SQLite3Connection1;

  SQLQuery1.Database := SQLite3Connection1;
  SQLQuery1.Transaction := SQLTransaction1;
  SQLQuery1.SQL.Text := 'SELECT * FROM Person';

  Datasource1.dataset := SQLQuery1;
  DBGrid1.Datasource := DataSource1;



  SQLite3Connection1.Open;
  If SQLite3Connection1.Connected then
  begin
    Connect.caption := 'Connected';
  end;
end;                           
« Last Edit: January 02, 2016, 07:34:25 pm by sunbreezy393 »

rvk

  • Hero Member
  • *****
  • Posts: 3836
Re: SQLite3Connection Connected, But Does Not Display Values Within The Grid
« Reply #1 on: January 02, 2016, 06:39:25 pm »
You forgot to "run" the query.

SQLQuery1.Active := true;
or
SQLQuery1.Open;

sunbreezy393

  • New Member
  • *
  • Posts: 11
Re: SQLite3Connection Connected, But Does Not Display Values Within The Grid
« Reply #2 on: January 02, 2016, 07:34:02 pm »
Thank you very much, it works  :)