[go: up one dir, main page]

0% found this document useful (0 votes)
288 views2 pages

FireDAC-First App

FireDAC offers TDataSet descendant classes like TADQuery and TADTable that have properties similar to BDE and TClientDataSet classes. The underlying architecture is more similar to recent dbExpress and ADO.NET, with data access classes representing commands and record sets. To build a simple application, minimum components needed are an ADConnection, ADQuery hooked to the connection, a DataSource, and visual components like a DBGrid. Steps are to set the connection's DriverName and database file params, set the query's connection and SQL, activate the dataset, and connect the grid to display data. Additional components ADPhysIBDriverLink and ADGUIxWaitCursor reference required units.

Uploaded by

Sinisa Nenkov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
288 views2 pages

FireDAC-First App

FireDAC offers TDataSet descendant classes like TADQuery and TADTable that have properties similar to BDE and TClientDataSet classes. The underlying architecture is more similar to recent dbExpress and ADO.NET, with data access classes representing commands and record sets. To build a simple application, minimum components needed are an ADConnection, ADQuery hooked to the connection, a DataSource, and visual components like a DBGrid. Steps are to set the connection's DriverName and database file params, set the query's connection and SQL, activate the dataset, and connect the grid to display data. Additional components ADPhysIBDriverLink and ADGUIxWaitCursor reference required units.

Uploaded by

Sinisa Nenkov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

FireDAC- First Application

FireDAC offers ready to use TDataSet descendant classes, like TADQuery, TADMemTable,
TADStoredProc, and TADTable. They tend to have properties very similar to the
corresponding BDE classes and the TClientDataSet. There are some more differences
with the dbExpress datasets.
The underlying architecture, however, is more similar to recent versions of dbExpress
and with ADO.NET, with data access classes representing commands and record sets.
But this is a more advanced topic, good for a future tip.
Let's start by building a simple VCL application (FireMonkey one will be similar, of course,
and Ill build it next). The minimum set of components you need is:
The ADConnection component with minimal database configuration
An ADQuery component hooked with the connection (it connects automatically as you
drop it in a designer with a connection). The query has a SQL text string list property, as in
the BDE. As an alternative you can use an ADTable component
A DataSource component connected with the query
The proper visual components, in the simplest scenario a DBGrid control.

The minimal steps to have a running application are:

In the connection component pick a value for the DriverName property, like IB for
InterBase
In the Params property enter the database file name, for example:
Database=C:\Embarcadero\InterBase\examples\database\employee.gdb and add
username and password
Eventually disable the LoginPrompt property, and try to connect (Connected = True)
Set the Connection property of the ADQuery component to the connection, if not already
done
Edit the SQL string list property with the SQL text like select * from Employee
Activate the dataset
Connect the DataSource to the dataset and the grid to the data source, and you should
see the data, as below:
To be able to deploy this application you need to add two more components, which effect is only
to add references to the required units for the database driver and the hourglass:

The ADPhysIBDriverLink brings in the uADPhysIB unit and is the driver for connecting
with the client library (no driver DLL to deploy like in dbExpress, as it is all in Delphi source
code)
The ADGUIxWaitCursor component bring in the uADGUIxFORMSWait unit. In the
component you can pick a Provider, which can be either Forms for VCL (the default, so
nothing to change here), Console, or FMX for FireMonkey
In theory you could remove both components and the program will still run, given the referenced
units, but it does make sense to keep the components around anyway. If you forget these
components, youll get runtime exceptions indicating quite clearly you need to add those
components to your application.
This is all to get a first demo up and running. Given the source code is close to nothing (I added
a line to open the query as the program starts), the relevant source code file is the DFM, with the
component properties. The summary is listed below:

object Form7: TForm7


OnCreate = FormCreate
object DBGrid1: TDBGrid
DataSource = DataSource1
end
object ADConnection1: TADConnection
Params.Strings = ('Database=C:\Embarcadero\InterBase\
examples\database\employee.gdb'
'User_Name=SYSDBA'
'Password=masterkey'
'Protocol=TCPIP'
'Server=localhost'
'DriverID=IB')
Connected = True
LoginPrompt = False
end
object DataSource1: TDataSource
DataSet = ADQuery2
end
object ADQuery2: TADQuery
Active = True
Connection = ADConnection1
SQL.Strings = ('select * from employee')
end
object ADPhysIBDriverLink1: TADPhysIBDriverLink
object ADGUIxWaitCursor1: TADGUIxWaitCursor
end

You might also like