SeriesArticleNavigation
- Using flex in Adobe AIR to connect to the SQLite database (1) (creating databases and tables)
- Use flex in Adobe AIR to connect to the SQLite database (2) (add, delete, modify, and statement parameters)
- Connecting to the SQLite database using flex in Adobe AIR (3) (query)
- Connecting to the SQLite database using flex in Adobe AIR (4) (Transaction)
- Index of flex and fms3 articles
- 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