First Steps to Use FireDAC - RAD Studio

April 8, 2017 | Author: Juli Adi Prastyo | Category: N/A
Share Embed Donate


Short Description

Download First Steps to Use FireDAC - RAD Studio...

Description

First Steps to Use FireDAC - RAD Studio

1 of 3

http://docwiki.embarcadero.com/RADStudio/XE5/en/First_Steps_to_Use...

Show: Delphi C++ Display Preferences

First Steps to Use FireDAC From RAD Studio Go Up to Getting Started (FireDAC) This article guides you through the creation of your first application built using the Delphi edition of FireDAC.

Contents 1 Introduction 2 Establishing the Connection to the Database 3 Selecting Rows from the Database 4 Preparing the Application for Run Time 5 Summary 6 See Also

Introduction This tutorial has three main sections: Establishing the connection to the database: how to use Delphi to create an application that will connect to a database. Selecting rows from the database: hook the data up to a grid and display it at design time. Preparing the application for run time: describes the necessary steps to make an application run as a standalone executable (run time). The screenshots and instructions below relate to RAD Studio 2007, so there might be minor changes if you use a different RAD Studio release. Also see the Ron Grove movie: First Steps to Use FireDAC (http://www.youtube.com/watch?feature=player_embedded&v=pZB5_VJfi2Y) .

Establishing the Connection to the Database In this article, we use the Microsoft SQL Server's Northwind demo database and a predefined connection definition - MSSQL_Demo. Let's start by creating a new "VCL Forms Application Delphi for Win32". First, drop a TFDConnection component onto the form selected from the "FireDAC" page of the RAD Studio Tool Palette. This component is responsible for establishing and controlling the database connection. Next, select MSSQL_Demo from the dropdown list of its ConnectionDefName property. This associates the connection component with the specified connection definition. By using the predefined definitions, you do not need to enter any additional parameters (such as the server name or the default database). After you set the Connected property to True, FireDAC displays a Login Dialog:

Here you can enter your user credentials. By default, you have three attempts to enter valid credentials. If they all fail, the login process also fails and you will get an error message. Press the OK button to establish the connection to the DB and to create a user session on the DBMS if this DBMS supports this feature.

12/24/2013 3:51 PM

First Steps to Use FireDAC - RAD Studio

2 of 3

http://docwiki.embarcadero.com/RADStudio/XE5/en/First_Steps_to_Use...

After the connection is successfully established, the Connected property should still be set to True, otherwise it will be reset to False and FireDAC will display an appropriate error message.

Selecting Rows from the Database Now drop a TFDQuery component from the "FireDAC" palette page onto the form. This component is responsible for the execution of SQL commands, fetching rows from the DB and for posting changed data back to the DB. Set its Connection property to FDConnection1 to hook the query to a database connection. Note: If a query component is dropped on a form or a datamodule that already contains one or more TFDConnections, FireDAC automatically sets the query's Connection property to point to the connection that was created first. Click on its SQL property and enter the following SQL command into the editor window: SELECT * FROM Orders

Press the OK button to close the editor. This stores the SQL command text into the TFDQuery component's SQL property. Next, drop a standard Delphi TDataSource component from the "Data Access" palette page onto your form. Set its DataSet property to FDQuery1. Now drop a TDBGrid control onto the form from the "Data Controls" page and set its DataSource property to DataSource1. Finally, set FDQuery1's Active property to True. This sends the SQL command to the DBMS, which executes the command and returns a result set. This data is displayed by the DBGrid1 control:

Preparing the Application for Run Time To allow your application to work at run time you need to: Drop the TFDPhysMSSQLDriverLink component from the "FireDAC Links" palette page Drop the TFDGUIxWaitCursor component from the "FireDAC UI" palette page Now your application is ready to run. These components assure that the necessary units get linked into your application executable. For real world applications, these components are typically dropped on a main data module.

Summary

12/24/2013 3:51 PM

First Steps to Use FireDAC - RAD Studio

3 of 3

http://docwiki.embarcadero.com/RADStudio/XE5/en/First_Steps_to_Use...

This article has provided a tutorial showing how to create a simple client-server application using FireDAC for Delphi. It shows how to use the FireDAC connection and query components to establish a connection to the DB and return rows to the client without actually writing any code. We suggest that you also read the Setting up Connections article for all the details on how to setup the connection definitions. For other DBMS Getting Started demo applications, see the FireDAC\Samples\Getting Started folder.

See Also Overview (FireDAC) Setting up Connections (FireDAC) Mobile Tutorial: Using FireDAC in Mobile Applications (iOS and Android) Retrieved from "http://docwiki.embarcadero.com/RADStudio/XE5/e/index.php?title=First_Steps_to_Use_FireDAC&oldid=211295" Category: FireDAC This page was last modified on 25 October 2013, at 17:29. Help Feedback

12/24/2013 3:51 PM

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF