To facilitate the test, I copied a copy of the official C:\Users\Public\Documents\Embarcadero\Studio\14.0\Samples\data\FDDemo.sdb to C:\Temp\. Fddemo.sdb.
{Create a new VCL Forms Application, then add the following controls (recommended by pressing Ctrl + . After adding with keyboard input):}
TFDPhysSQLiteDriverLink // is used to drive automatic connections; one for each database: TFDPhys****DriverLink
TFDGUIxWaitCursor // "waiting cursor" for automatic management of GUI programs; similar things in Console and FMX
TFDConnection // data connection
TFDQuery // data query
TDataSource // data source
TDBGrid // data display
// After using FireDAC.Phys.SQLite, you don't need to add TFDPhysSQLiteDriverLink
// After using FireDAC.VCLUI.Wait, you don't need to add TFDGUIxWaitCursor
{Simply a few lines of code that renders the data in the Orders table in FDDemo.sdb}
Procedure TForm1.FormCreate(Sender: TObject);
Begin
FDConnection1.DriverName := 'SQLite';
FDConnection1.Params.Add('Database=C:\Temp\FDDemo.sdb');
FDQuery1.Connection := FDConnection1;
DataSource1.DataSet := FDQuery1;
DBGrid1.DataSource := DataSource1;
FDQuery1.SQL.Text := 'SELECT * FROM Orders'; // SQLite supports the SQL92 standard very well, and is currently ignored: http://www.sqlite.org/omitted.html
FDConnection1.Open();
FDQuery1.Open();
DBGrid1.Align := alClient;
End;
{Slightly change the code}
Procedure TForm1.FormCreate(Sender: TObject);
Begin
// FDConnection1.ConnectionString := 'DriverID=SQLite; Database=C:\Temp\FDDemo.sdb'; // Can replace the following two lines
FDConnection1.Params.Add('DriverID=SQLite'); // Same as FDConnection1.DriverName := 'SQLite';
FDConnection1.Params.Add('Database=C:\Temp\FDDemo.sdb');
FDQuery1.Connection := FDConnection1;
DataSource1.DataSet := FDQuery1;
DBGrid1.DataSource := DataSource1;
FDQuery1.SQL.Text := 'SELECT * FROM Orders';
FDConnection1.Connected := True;
FDQuery1.Active := True;
DBGrid1.Align := alClient;
End;
{Change it again}
procedure TForm1.FormCreate(Sender: TObject);
begin
FDQuery1.Connection := FDConnection1;
DataSource1.DataSet := FDQuery1;
DBGrid1.DataSource := DataSource1;
FDConnection1.Open('DriverID=SQLite;Database=C:\Temp\FDDemo.sdb');
FDQuery1.Open('SELECT * FROM Orders');
DBGrid1.Align := alClient;
end;