In order to facilitate the test, I copied the official C:\Users\Public\Documents\Embarcadero\Studio\14.0\Samples\data\FDDemo.sdb for a copy to
C:\Temp\FDDemo.sdb.
{Create a new VCL Forms application, and then add the following controls (it is recommended to press Ctrl +. After adding with keyboard input):}Tfdphyssqlitedriverlink//for driving automatic connection; Each of the different databases corresponds to one: Tfdphys****driverlinkTfdguixwaitcursor//"Waiting cursor" for automatic management of GUI programs; There are similar things in the Console and the FMX.Tfdconnection//Data connectionTfdquery//Data queryTdatasource//Data sourceTDBGrid//Data displayAfter uses FireDAC.Phys.SQLite, you do not have to add TfdphyssqlitedriverlinkAfter uses FireDAC.VCLUI.Wait, you do not have to add tfdguixwaitcursor{A few lines of code render the data in the Orders table in Fddemo.sdb}procedureTform1.formcreate (Sender:tobject);beginFdconnection1.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 only: http://www.sqlite.org/omitted.htmlFdconnection1.open (); Fdquery1.open (); Dbgrid1.align: = alclient;End;
:
{Slightly modify the code}procedureTform1.formcreate (Sender:tobject);beginFdconnection1.connectionstring: = ' driverid=sqlite; Database=c:\temp\fddemo.sdb '; Can replace the following two linesFDCONNECTION1.PARAMS.ADD (' Driverid=sqlite '); With 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; {A little more flexible}procedureTform1.formcreate (Sender:tobject);beginFdquery1.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;