Connecting to the SQLite database using flex in Adobe AIR (4) (Transaction)

Source: Internet
Author: User
SeriesArticleNavigation
  1. Using flex in Adobe AIR to connect to the SQLite database (1) (creating databases and tables)
  2. Use flex in Adobe AIR to connect to the SQLite database (2) (add, delete, modify, and statement parameters)
  3. Connecting to the SQLite database using flex in Adobe AIR (3) (query)
  4. Connecting to the SQLite database using flex in Adobe AIR (4) (Transaction)
  5. Index of flex and fms3 articles
  6. Free beauty video chat, multi-person video conferencing feature enhanced version (fms3 and flex development (with source code ))

This chapter mainly summarizes the transaction control in data operations.
Since SQL statements in SQLite do not support transactions, we can use this function through the transaction-related methods of the sqlconnection class: sqlconnection. begin (), sqlconnection. commit () and sqlconnection. rollback () to implement the transaction function.

For more information about SQL support in the air local database, see
Http://help.adobe.com/zh_CN/AIR/1.5/jslr/index.html? Localdatabasesqlsupport.html

Transaction instanceCode:
Import MX. Controls. Alert;
Private var con: sqlconnection;

Private function initapp (): void
{
Var file: file = file. applicationstoragedirectory. resolvepath ("mytestdb. DB ")
Con = new sqlconnection ();
VaR stmt: sqlstatement = new sqlstatement ();
 
Try
{
Con. Open (File );

Con. Begin ();
Stmt. sqlconnection = con;
Stmt. Text = "insert into EMP (firstname, lastname, salary) values ('F', 'l', 1110 )";
Stmt.exe cute ();
Con. Commit ();
}
Catch (ERR: sqlerror)
{
Con. rollback ();
Alert. Show (ERR. Message );
}
}
Code Description:
The transaction starts from the begin method. If n SQL statements run during the transaction are successful, they are committed by the commit method. If any SQL statement has an error, all the rollback statements are rolled back by the rollback method. the code is relatively simple. People with suggestions for development in other languages can understand it at a glance.

 

Download Code:
Http://files.cnblogs.com/aierong/Air_Test_SQLite4.rar

 

Favorites and sharing

Add QQ bookmarks to Baidu souzang and Yahoo favorites

RSS subscribe to me What is RSS?




Dongguan. Net Club

Welcome to join

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.