Delphi xe4 for iOS: SQLite preliminary test

Source: Internet
Author: User

The official developer of SQLite has given a simple example, the address of this example is http://docwiki.embarcadero.com/RADStudio/XE4/en/IOS_Tutorial:_Using_SQLite_in_an_iOS_Application.

In this exampleDbexpressControls for database connection.DbexpressThis is not very useful, and I do not like it very much.

So I switched to Unidac and firedac to redo this demo, where firedac is a http://altd.embarcadero.com/download/radstudio/xe4/FireDAC_8.0.1.3279.exe, Unidac can be found in the box, here is not provided.

CodeIn fact, they are all similar and basically do not need to be modified. The problem with switching to the two controls is that Chinese characters are garbled and it takes a lot of time to share your experience with you. In addition, the SQLite files are not encrypted at present, and the two data controls with passwords cannot be connected. There is actually a way to solve the problem by adding a password to firedac. This control comes with an encrypted function. However, if you use the function encryption provided by it, the third-party management tool cannot be connected. It is very troublesome to remove the password every time you connect, my third-party management tools are SQLite expert professional 3 and navicat for SQLite. We recommend that you use SQLite expert professional to create a database. Otherwise, the encoding problem may be confusing.

Follow the official demo to create the corresponding database file. Remember to select Unicode as the encoding when creating the database. Otherwise, Chinese characters will be garbled. For Unidac

Select true for useunicode. In addition, all fields involved in the operation are of the widestring type. Otherwise, garbled characters will occur. A running Graph

For firedac, setting the stringformat attribute to Unicode takes some time to search for it. Then, the field operation is the same as before. The widestring type is used.

The code for adding a button is:

 Procedure  Tform2.btninsertclick (Sender: tobject );  VaR  Shopitem: string;  Begin  Try  If Inputquery ( '  Enter New shopitem  ' , '  Shopitem  ' , Shopitem) And   Not (Shopitem. Trim = '' ) Then      Begin  Adqueryinsert. parambyname (  '  Shopitem  ' ). Aswidestring: = Shopitem; adqueryinsert. execsql (); adtable1.refresh; linkfillcontroltofield1.bindlist. filllist;  End  ; Except T on E: exception  Do     Begin  Showmessage (E. Message );  End  ;  End  ;  End ;

The widestring type is not a problem.

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.