Delphi APP opens (eight) SQLite information repository

Source: Internet
Author: User
Tags sqlite download

Delphi APP opens (eight) SQLite information library share:Share on FacebookShare on TwitterShare on Google_plusone_sharestated expiry Refer reads: 5279 發表時間:2014/06/25Tags: mobile education App Delphi XE6 Android IOS SQLite

Delphi APP opens Door (vii) notification and cloud-side push << previously

When writing an app, if you encounter information that is not relevant and the amount of information is not much, it will be stored like an XML file, but once you encounter a complex and large amount of information, you need to use the library to do the records. Today's Delphi app opens to teach you how to write a library app, where we use the ultra-lightweight version of the file repository system-sqlite.

In the formal writing of the program, we need to first build a new SQLite library, first of all we must go to the official website of SQLite download two files.

1 Sqlite-dll–delphi XE6 This file is required to be downloaded and then compressed into the System32 folder when the development tool is connected to the repository.

2 Sqlite-shell–sqlite command-line tool, download and create a SQLite folder in C slot to compress here.

First, the establishment of SQLite information repository

Start = Execute input cmd.exe enter command-line mode

Input in sequential

Sqlite3             Note: Enter the sqlite3 command-line mode. Save Todolist.db   Note: Save a repository called todolist.db. Quit               Note: Leave sqlite3 command-line mode

Second, after the establishment of the library, you can return to Delphi XE6 add a new mobile application program, next we click on the right hand side of the data Explorer, you can see two ways (Firedac and dbexpress), Let's choose dbexpress first.

Third, choose SQLite Right-click, Add New Connection

Four, the name named ToDoList

Five, the database into the todolist.db full path c:\sqlite\todolist.db

Vi. Press advanced to set Failifmissing to False, which means true if the information library does not exist when it is false, and if it does not exist, create one. Press OK to exit, and finally press Test connection to confirm the completion.

After the establishment of the Information Library link, then the establishment of the Information table, click on the new ToDoList tables right-click New table

Eight, add a linked fields bit for the Todoitem, information type (Data type) as text

After the establishment, press Save table to save the TODO table

After the information library is connected, we start to create the following screen, first put a top toolbar on the canvas, put a label in place and the Left and right buttons (a new, delete), and finally put the listbox display the information of the

And then we're going to link the information to the program in a very simple way, by dragging the left-click of the TODO table to the canvas, you can see the animated todolistconnection on the canvas and the todotable two DBX elements.

12. Then we're going to set Todolistconnection's connected to True, Todotable's active is set to true. Make sure the connection to the repository is open.

13. Then we select Livebindings Designer from the View main menu.

14. Livebindings Designer is Embarcadero's great information link technology that uses a visual approach to connect information to components. Here we are going to show the Todoitem in the todotable what to do in the listbox? It is simple to drag the Todoitem in Todotable to ListBox1 Item.text. After the connection is complete, an arrow appears, indicating that the Todoitem is to be displayed in the Item.text of the listbox.


And then we're going to actually add a new feature, first put a tsqlquery,name on the canvas and set the todoaddquery,sqlconnection as Todolistconnection, and then the SQL command

Insert into Todo (ToDoItem) Values (: ToDoItem)


16. After setting, select the Todoitem of the params and we will set datatype as ftstring (text)

17. Add the following code to the new button on the canvas

18, then we want to actually practices remove the function, repeat, 72 steps. Name the new query named Tododelquery,sql.

Delete from Todo where ToDoItem =: ToDoItem


19. Add the following code to the Delete button on the canvas

20, then we want to enter in the ListBox, if there is information to delete the button, without the information hidden Delete button, in the Listboxitemclick to write into the following program

21, then we want to add sqlite information in the deployed program, go to project = Deployment, click Add Files, select C \ The Todolist.db,platform under SQLite is first set to Android, and then the Remote path is assets\internal\


22. Finally, we want to make an action that ensures that the repository is built. First, add system.ioutils to the uses of the code.

And then in Todolistconnectionbeforeconnect Plus

and Todolistconnectionafterconnect Plus

Perform the painting

Delphi APP opens (eight) SQLite information repository

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.