SQLite in the FIREDAC (II.)

Source: Internet
Author: User
Tags sqlite

We're going to use the fddemo.sdb database to access it and start our first SQLite access example.

Our Fddemo.sdb storage directory is in:C:\Program Files (x86) \embarcadero\studio\14.0\samples\data

New VCL Forms Application

Press Ctrl +. key in the XE6 IDE to quickly enter the VCL forms application, and a new VCL forms application application is created after carriage return.

Adding FIREDAC related components

Continue to press CTRL +. Key to quickly enter the following characters, create the following components:

Fdphyssqlitedriverlink    //SQLite Driver Auto Connect component, equivalent to uses FireDAC.Phys.SQLite;fdguixwaitcursor          // The waiting cursor for automatic management of GUI programs, equivalent to uses FireDAC.VCLUI.Wait; Fdconnection              // data connection fdquery                   // data query DataSource                // Data Source DBGrid                    // data table display

When added, the IDE looks like the effect:

Next we enter a simple code, as follows:

proceduretform1.formcreate (sender:tobject);varDbstr:string;begin  //set the path to the Fddemo.sdbDBSTR: ='C:\Program Files (x86) \embarcadero\studio\14.0\samples\data\fddemo.sdb'; Fdconnection1.drivername:='SQLite'; FDCONNECTION1.PARAMS.ADD ('database='+dbstr); Fdquery1.connection:=FDConnection1; Datasource1.dataset:=FDQuery1; Dbgrid1.datasource:=DataSource1; FDQuery1.SQL.Text:='SELECT * from Products';  Fdquery1.open ();  Fdconnection1.open (); Dbgrid1.align:=alclient;End;

OK, so far, we have completed a small example of SQLite, press F9 to start running it, the effect is as follows:

By looking at the teacher's code, we find that fdconnection can use ConnectionString to set up the connection content.

  //fdconnection1.drivername: = ' SQLite ';  // FDConnection1.Params.Add (' database= ' + dbstr), equivalent to the following line of code   fdconnection1.connectionstring:'driverid=sqlite; database=' + dbstr;

Of course the Fdconnection.open method and the Fdquery.open method support the following uses:

  Fdconnection1.open ('driverid=sqlite; database=' + dbstr);  Fdquery1.open ('SELECT *from Products');

The Open method directly assigns ConnectionString and SQL statements.

SQLite in the FIREDAC (II.)

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.