Contents. Before starting this tutorial, you should read and perform the following tutorial session:. This tutorial describes the basic steps to use SQLite as a local data storage on your mobile device through the FireDAC framework. IOS Android Using FireDAC to Connect to the Database FireDAC is a unique set of Universal Data Access for developing cross-platform database applications for Delphi and CBuilder. With its powerful common architecture, FireDAC enables native high-speed direct access from Delphi to InterBase, SQLite, MySQL, SQL Server, Oracle, PostgreSQL, IBM DB2, SQL Anywhere, Access, Firebird, Informix, and more.
Simple CRUD Apps With Delphi XE5 And MySQL Database| Design Part. Server - klien Koneksi dialog.
For the mobile platforms, FireDAC supports InterBase ToGo as well as SQLite. These database products can run on iOS and Android devices. For other databases, such as Oracle, you need to have at least a client library. On Windows platforms, the client library is provided as a DLL to connect to. Therefore, you need to develop applications using middle-tier technologies such as DataSnap REST to connect to these database products from a mobile device. For C: File New Multi-Device Application - CBuilder Blank Application. On the, double-click the TFDConnection component.
Right click the component and choose Connection Editor. In the FireDAC Connection Editor, set the following parameters of the:. Set the property to SQLite.
Set the Database parameter to: C: Users Public Documents Embarcadero Studio 20.0 Samples Data shoplist.s3db (location of the database) and click Open in the File Open dialog box. Note: You can set the above Database parameter even if shoplist.s3db does not exist, RAD Studio creates it automatically. (To display Employees.s3db or other.s3db files in the Open dialog, set the All Files (.) option.). Set the LockingMode parameter to normal.
Click the Test button to test the connection. Click OK to close the Connection Editor.
In the, set the following properties of TFDConnection:. Set the property to False, so that the user is not prompted for a login. Set the property to True. On the, double-click the TFDQuery component.
![Cara Menggunakan Delphi 7 Lite Cara Menggunakan Delphi 7 Lite](http://1.bp.blogspot.com/-Wj_HWk0dtiE/UXUGnMu8vRI/AAAAAAAAAiI/K4dLTfcgqyQ/s1600/2Table+BDE.jpg)
In the, set the following properties of TFDQuery:. Set the property to FDQueryCreateTable.
Set the SQL property as follows: CREATE TABLE IF NOT EXISTS Item (ShopItem TEXT NOT NULL). Right click the FDQueryCreateTable and choose Execute. Design and Set Up the User Interface.
Visible UI components are loaded on the designer This tutorial uses one component as the UI element. To set up a ListView component and other UI elements, use the following steps:. Drop a on the form. Drop a on the ToolBar component and set the following properties in the:. Set the property to ButtonAdd. Set the to addtoolbutton. Set the to Right.
Drop a on the ToolBar component and set the following properties in the:. Set the property to ButtonDelete. Set the to deletetoolbutton. Set the to Left. Set the to Delete. Set the property to False.
Drop a on the ToolBar component and set the following properties in the:. Set the to Client. Set the to toollabel. Set the to Shopping List.
Expand the node and set the property to Center. Drop a component on the form and set the following properties in the:.
Set the property to Client, so that the ListView component uses the entire form. Using the LiveBindings Wizard This tutorial uses the LiveBindings Wizard to add the LiveBindings components (, ), and the component. Add the LiveBinding components. Select View LiveBindings Designer and the opens.
Select Create a data source binding task. Click the Next button. Select FireDAC class name. Click the Next button. Change the Command Type to Query. Set the Command Text property to select ShopItem from Item.
Click the Test Command button. Click the Next button. Click the Finish button.
At this point, and components were added to your form. Connecting to the Data.
Reopen the. Select Link a control with a field binding task. Click the Next button.
Select the Existing Control tab. Select the ListView1 component. Click the Next button. Select BindSourceDB1. Click the Next button. Select ShopItem Field Name.
Click the Next button. Click the Finish button to close the wizard. Note: These last steps are not mandatory for this tutorial since there is only one field in BindSourceDB1. These steps are useful to link with the selected value if we are managing several fields of a database. Displaying ShopItem in the ListView The following step displays the text of ShopItem in the TListView component.
In the select ShopItem in the BindSourceDB1 component and drag ShopItem to Item.Text in ListView1. Following these steps connects the user interface of the app with data on a SQLite database. If you used a table with existing data for this tutorial, now you should see actual data within the Form Designer. Creating the Event Handler to Make the Delete Button Visible When the User Selects an Item from the List The property for the Delete button is set to False. Therefore, by default, the end user does not see this button. You can make it visible when the user selects an item on the list, as follows:. Select ListView1 and define the following event handler for the event.
Database connections are also configured The next step is adding a feature to this application for adding an item to the shopping list. Drop a component on the form. Set the following properties in the:. Set the property to FDQueryInsert. Set the SQL property as follows: INSERT INTO ITEM (ShopItem) VALUES (:ShopItem). Select the Expand (.) button on the property.
Select the ShopItem parameter and set to ftString:. In the, right-click the ButtonAdd component and select Control Bring to Front. This brings the button to the visual front of the active form. Procedure TForm1.
OnInputQueryClose ( const AResult: TModalResult; const AValues: array of string ); var TaskName: String; begin TaskName:= string. Empty; if AResult mrOk then Exit; TaskName:= AValues 0 ; try if ( TaskName. Trim ' ) then begin FDQueryInsert. ParamByName ( 'ShopItem' ). AsString:= TaskName; FDQueryInsert. ExecSQL ; FDQuery1.
Close ; FDQuery1. Open; ButtonDelete. Visible:= ListView1. Selected nil; end; except on e: Exception do begin ShowMessage ( e. Message ); end; end; end;. In the Form Designer, double-click the ButtonAdd component.
Add the following code to this event handler.