Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLiteµÄ·â×°Àà

package
{
import flash.data.SQLConnection;
import flash.data.SQLResult;
import flash.data.SQLStatement;
import flash.errors.SQLError;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
import flash.filesystem.File;

import mx.collections.ArrayCollection;

public class DBUtil
{
/**
* Êý¾Ý¿â²Ù×÷Àà±ð
**/
private const typeArr:Array = ['select','insert','update','delete','create','alter','drop'];

/**
* Á¬½Ó
**/
private var conn:SQLConnection;

/**
* ÉùÃ÷
**/
private var stmt:SQLStatement;

/**
* ½á¹û¼¯ºÏ
**/
private var rsAC:ArrayCollection;

public function DBUtil()
{
}

/**
* »ñµÃÁ¬½Ó
**/
private function getConn():SQLConnection
{
if(this.conn == null){
conn = new SQLConnection();
conn.addEventListener(SQLEvent.OPEN, sqlOpen);
conn.addEventListener(SQLErrorEvent.ERROR, sqlError);
}
return this.conn;
}

/**
* ¹Ø±ÕÁ¬½Ó
**/
private function closeConn():void
{
if(this.conn != null){
this.conn.close();
this.conn = null;
}
}

/**
* »ñµÃÉùÃ÷
**/
private function getStatement():SQLStatement
{
if(this.stmt == null)
{
stmt = new SQLStatement();
stmt.sqlConnection = getConn();
stmt.addEventListener(SQLErrorEvent.ERROR, sqlError);
}
return this.stmt;
}

/**
* ¹Ø±ÕÉùÃ÷
**/
private functio


Ïà¹ØÎĵµ£º

SQLiteµÄ²éѯÓÅ»¯

±¾ÆªÎÄÕÂÀ´Ô´ÓÚ£º¿ª·¢Ñ§Ôº http://edu.codepub.com   Ô­ÎÄÁ´½Ó£ºhttp://edu.codepub.com/2009/0825/14358.php
SQLiteÊǸöµäÐ͵ÄǶÈëʽDBMS£¬ËüÓкܶàÓŵ㣬ËüÊÇÇáÁ¿¼¶µÄ£¬ÔÚ±àÒëÖ®ºóºÜС£¬ÆäÖÐÒ»¸öÔ­Òò¾ÍÊÇÔÚ²éѯÓÅ»¯·½Ãæ±È½Ï¼òµ¥£¬ËüÖ»ÊÇÔËÓÃË÷Òý»úÖÆÀ´½øÐÐÓÅ»¯µÄ£¬¾­¹ý¶ÔSQLiteµÄ²éѯÓÅ»¯µÄ·ÖÎöÒÔ¼°¶ÔÔ´´úÂëµÄ ......

ÓÃvs2008±àÒë³ösqlite dllºÍlib (ͼ½â)

1£º´ÓsqliteµÄ¹ÙÍøÉÏÏÂÔØÔ´Âë http://www.sqlite.org/download.html
2£º´ò¿ªvs2008¹¤³Ìн¨Ò»¸ö¿ÕµÄdll¹¤³Ì¡£
3£º°Ñsqlite3.h,sqlite3.cpp,sqlite3.def·Ö±ð¼ÓÈëµ½head file ºÍsource fileÏ¡£
4£º±àÒë³ÌÐò¡£ ÕâʱֻÄܵõ½sqlite3.dllÎļþ¡£
5£º´ò¿ªvs2008×Ô´øµÄÃüÁîÐУº Çе½sqlite3.defËùÔÚµÄĿ¼¡£
 
6£ºÔËÐÐ ......

Android£¨Èý£©Êý¾Ý´æ´¢Ö®ÈýSQLiteǶÈëʽÊý¾Ý¿â

Ç°Á½ÆªÈÕÖ¾ÎÒÒѾ­×ܽáÁ˱¾µØÊý¾Ý´æ´¢µÄÇ°Á½ÖÖ£ºÎļþºÍÅäÖÃÏî¡£»¹Ê£ÏÂ×îºóÒ»ÖÖÊý¾Ý¿â´æ´¢——SQLite¡£
Ò»¡¢SQLite¼ò½é
ÔÚAndroidƽ̨ÉÏ£¬¼¯³ÉÁËÒ»¸öǶÈëʽ¹ØϵÐÍÊý¾Ý¿â—SQLite£¬SQLite3Ö§³Ö NULL¡¢INTEGER¡¢REAL£¨¸¡µãÊý×Ö£©¡¢TEXT(×Ö·û´®Îı¾)ºÍBLOB(¶þ½øÖƶÔÏó)Êý¾ÝÀàÐÍ£¬ËäÈ»ËüÖ§³ÖµÄÀàÐÍËäȻֻÓÐÎåÖÖ ......

SQLiteÆô¶¯ÊÂÎï

ÊÂÎñ£¨DbTransaction£©£º
SQLite ȱʡΪÿ¸ö²Ù×÷Æô¶¯Ò»¸öÊÂÎñ£¬ËùÒÔ³ÉÅú²åÈëµÄʱºò£¬Æô¶¯ÊÂÎñ£¬±È²»Æô¶¯ÊÂÎñ¿ìn±¶¡£
ÔÚûÆô¶¯ÊÂÎñ֮ǰÍùSqliteÊý¾Ý¿âÀï²åÈë1000¶àÌõÊý¾ÝµÄÇé¿ö,½á¹ûÿ´Î¶¼ÐèÒªÒ»Á½·ÖÖÓ²ÅÄÜÍê³É.
¶øÔÚÆô¶¯ÊÂÎïÒÔºóËùÐèÒªµÄʱ¼äÖ±½Ó±ä³É²»µ½2Ãë!Ô­À´sqlite»¨Á½·ÖÖÓÊÇÓÉÓÚExecuteNonQuery·½·¨Ö´ÐÐʱ×Ô¼ºÌá½» ......

SQLiteÊý¾Ý¿â

@ǶÈëʽ¹ØϵÐÍÊý¾Ý¿âSQLite
    Ìصã
        1.Ö§³ÖÎåÖÖÊý¾ÝÀàÐÍ null,INTEGER,REAL(¸¡µãÊý),TEXT(×Ö·û´®Îı¾)ºÍBLOB£¨¶þ½øÖÆÎı¾£©Êý¾ÝÀàÐÍ£¬ËäÈ»
        ËüÖ»ÓÐÎåÖÖ£¬µ«Êµ¼ÊÉÏsqlite3Ò²½ÓÊÖvarcher(n),char(n),decimal(p,s)µÈÊý¾ÝÀàÐÍ£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ