Sqlite under FireDAC [2]-the first example

Source: Internet
Author: User


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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.