用戶資料管理系統。flex 操作sqlite數據庫的例子。要的給我發郵件
一些源碼:
import mx.controls.Alert;
private var conn:SQLConnection;
private var SQLStatetmt:SQLStatement;
private var file:File;
private var arr:Array=["姓名","性別","年齡","手機號碼","家庭號碼","QQ號碼","郵箱號碼"];
private function init():void
{
try
{
file=File.applicationDirectory.resolvePath("UserInfoDB.db");
conn=new SQLConnection();
SQLStatetmt=new SQLStatement();
conn.open(file);//打開SQL連接
}
catch(error:SQLError)
{
Alert.show(error.message);
Alert.show(error.details);
}
createTable();
}
private function createTable():void
{
try
{
SQLStatetmt.sqlConnection=conn;
var sql:String ="CREATE TABLE IF NOT EXISTS TelInfoTable(Id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name TEXT unique,sex TEXT,age numeric CHECK(200>age>0),mobilephone TEXT," +
"homephone TEXT,qq TEXT,eMails TEXT)";
SQLStatetmt.text=sql;
SQLStatetmt.execute();
}
catch(error:SQLError)
{
Alert.show(error.message);
Alert.show(error.details);
}
}
private function createTableOK(event:SQLEvent):void
{
Alert.show("ccccccc");
insertTable();
}
private function selectTable():void
{
try
{
//SQLStatetmt.sqlConnection=conn;
SQLStatetmt.text="select * from TelInfoTable";
SQLStatetmt.execute();
var result:SQLResult = SQLStatetmt.getResult();
if(result.data == null)
{
Alert.show("查不到相應的數據");
return;
}
var obj:Object=result.data;
datagrid1.dataProvider=obj;
var len:int=result.data.length;
}
catch(error:SQLError)
{
Alert.show(error.message);
Alert.show(error.details);
}
}
一些源碼:
import mx.controls.Alert;
private var conn:SQLConnection;
private var SQLStatetmt:SQLStatement;
private var file:File;
private var arr:Array=["姓名","性別","年齡","手機號碼","家庭號碼","QQ號碼","郵箱號碼"];
private function init():void
{
try
{
file=File.applicationDirectory.resolvePath("UserInfoDB.db");
conn=new SQLConnection();
SQLStatetmt=new SQLStatement();
conn.open(file);//打開SQL連接
}
catch(error:SQLError)
{
Alert.show(error.message);
Alert.show(error.details);
}
createTable();
}
private function createTable():void
{
try
{
SQLStatetmt.sqlConnection=conn;
var sql:String ="CREATE TABLE IF NOT EXISTS TelInfoTable(Id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name TEXT unique,sex TEXT,age numeric CHECK(200>age>0),mobilephone TEXT," +
"homephone TEXT,qq TEXT,eMails TEXT)";
SQLStatetmt.text=sql;
SQLStatetmt.execute();
}
catch(error:SQLError)
{
Alert.show(error.message);
Alert.show(error.details);
}
}
private function createTableOK(event:SQLEvent):void
{
Alert.show("ccccccc");
insertTable();
}
private function selectTable():void
{
try
{
//SQLStatetmt.sqlConnection=conn;
SQLStatetmt.text="select * from TelInfoTable";
SQLStatetmt.execute();
var result:SQLResult = SQLStatetmt.getResult();
if(result.data == null)
{
Alert.show("查不到相應的數據");
return;
}
var obj:Object=result.data;
datagrid1.dataProvider=obj;
var len:int=result.data.length;
}
catch(error:SQLError)
{
Alert.show(error.message);
Alert.show(error.details);
}
}
沒有留言:
張貼留言